jfolz: Tiny niggle: It now says "Str is too large" instead of "Bytes is too large" in 2.7 if the object exceeds `ITEM_LIMIT`.
diff --git a/msgpack/_packer.pyx b/msgpack/_packer.pyx
index f24aa70..5a81709 100644
--- a/msgpack/_packer.pyx
+++ b/msgpack/_packer.pyx
@@ -10,6 +10,8 @@ from msgpack import ExtType
 cdef extern from "Python.h":
 
     int PyMemoryView_Check(object obj)
+    int PyByteArray_Check(object obj)
+    int PyByteArray_CheckExact(object obj)
 
 
 cdef extern from "pack.h":
@@ -39,6 +41,14 @@ cdef int DEFAULT_RECURSE_LIMIT=511
 cdef size_t ITEM_LIMIT = (2**32)-1
 
 
+cdef inline int PyBytesLike_Check(object o):
+    return PyBytes_Check(o) or PyByteArray_Check(o)
+
+
+cdef inline int PyBytesLike_CheckExact(object o):
+    return PyBytes_CheckExact(o) or PyByteArray_CheckExact(o)
+
+
 cdef class Packer(object):
     """
     MessagePack Packer
@@ -174,10 +184,10 @@ cdef class Packer(object):
                 else:
                    dval = o
                    ret = msgpack_pack_double(&self.pk, dval)
-            elif PyBytes_CheckExact(o) if strict_types else PyBytes_Check(o):
+            elif PyBytesLike_CheckExact(o) if strict_types else PyBytesLike_Check(o):
                 L = len(o)
                 if L > ITEM_LIMIT:
-                    raise PackValueError("bytes is too large")
+                    raise PackValueError("%s is too large" % type(o).__name__)
                 rawval = o
                 ret = msgpack_pack_bin(&self.pk, L)
                 if ret == 0:
diff --git a/msgpack/fallback.py b/msgpack/fallback.py
index 508fd06..a02cbe1 100644
--- a/msgpack/fallback.py
+++ b/msgpack/fallback.py
@@ -38,6 +38,8 @@ if hasattr(sys, 'pypy_version_info'):
         def write(self, s):
             if isinstance(s, memoryview):
                 s = s.tobytes()
+            elif isinstance(s, bytearray):
+                s = bytes(s)
             self.builder.append(s)
         def getvalue(self):
             return self.builder.build()
@@ -728,10 +730,10 @@ class Packer(object):
                     default_used = True
                     continue
                 raise PackOverflowError("Integer value out of range")
-            if check(obj, bytes):
+            if check(obj, (bytes, bytearray)):
                 n = len(obj)
                 if n >= 2**32:
-                    raise PackValueError("Bytes is too large")
+                    raise PackValueError("%s is too large" % type(obj).__name__)
                 self._pack_bin_header(n)
                 return self._buffer.write(obj)
             if check(obj, Unicode):

can't serialize bytearray
If value = bytearray(b'\x01\x87h\x05')

then packb(value, use_bin_type=True)

returns the error: can't serialize bytearray(b'\x01\x87h\x05')

Is this a known problem?
diff --git a/test/test_pack.py b/test/test_pack.py
index e945902..a704fdb 100644
--- a/test/test_pack.py
+++ b/test/test_pack.py
@@ -58,6 +58,13 @@ def testPackBytes():
     for td in test_data:
         check(td)
 
+def testPackByteArrays():
+    test_data = [
+        bytearray(b""), bytearray(b"abcd"), (bytearray(b"defgh"),),
+        ]
+    for td in test_data:
+        check(td)
+
 def testIgnoreUnicodeErrors():
     re = unpackb(packb(b'abc\xeddef'), encoding='utf-8', unicode_errors='ignore', use_list=1)
     assert re == "abcdef"

pip install -e .
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
certifi==2021.5.30
Cython==0.25.2
importlib-metadata==4.8.3
iniconfig==1.1.1
-e git+https://github.com/msgpack/msgpack-python.git@a8d9162ca6cff6101c1f6b9547e94749c6acae96#egg=msgpack_python
packaging==21.3
pluggy==1.0.0
py==1.11.0
pyparsing==3.1.4
pytest==7.0.1
tomli==1.2.3
typing_extensions==4.1.1
zipp==3.6.0

name: msgpack-python
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - cython==0.25.2
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - packaging==21.3
      - pluggy==1.0.0
      - py==1.11.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - zipp==3.6.0
prefix: /opt/conda/envs/msgpack-python

test/test_pack.py::testPackByteArrays
test/test_pack.py::testPack test/test_pack.py::testPackUnicode test/test_pack.py::testPackUTF32 test/test_pack.py::testPackBytes test/test_pack.py::testIgnoreUnicodeErrors test/test_pack.py::testStrictUnicodeUnpack test/test_pack.py::testStrictUnicodePack test/test_pack.py::testIgnoreErrorsPack test/test_pack.py::testNoEncoding test/test_pack.py::testDecodeBinary test/test_pack.py::testPackFloat test/test_pack.py::testArraySize test/test_pack.py::test_manualreset test/test_pack.py::testMapSize test/test_pack.py::test_odict test/test_pack.py::test_pairlist
msgpack/_packer.pyx msgpack/fallback.py
msgpack/_packer.pyx msgpack/fallback.py