diff --git a/twitter/__init__.py b/twitter/__init__.py
index 87bb718..0534776 100644
--- a/twitter/__init__.py
+++ b/twitter/__init__.py
@@ -23,7 +23,7 @@ __author__       = 'The Python-Twitter Developers'
 __email__        = 'python-twitter@googlegroups.com'
 __copyright__    = 'Copyright (c) 2007-2016 The Python-Twitter Developers'
 __license__      = 'Apache License 2.0'
-__version__      = '3.2'
+__version__      = '3.2.1'
 __url__          = 'https://github.com/bear/python-twitter'
 __download_url__ = 'https://pypi.python.org/pypi/python-twitter'
 __description__  = 'A Python wrapper around the Twitter API'
diff --git a/twitter/twitter_utils.py b/twitter/twitter_utils.py
index 081d1ed..0b2af5b 100644
--- a/twitter/twitter_utils.py
+++ b/twitter/twitter_utils.py
@@ -161,12 +161,13 @@ def calc_expected_status_length(status, short_url_length=23):
         Expected length of the status message as an integer.
 
     """
-    replaced_chars = 0
-    status_length = len(status)
-    match = re.findall(URL_REGEXP, status)
-    if len(match) >= 1:
-        replaced_chars = len(''.join(match))
-    status_length = status_length - replaced_chars + (short_url_length * len(match))
+    status_length = 0
+    for word in re.split(r'\s', status):
+        if is_url(word):
+            status_length += short_url_length
+        else:
+            status_length += len(word)
+    status_length += len(re.findall(r'\s', status))
     return status_length
 
 

calc_expected_status_length does not work
calc_expected_status_length is broken in two ways right now. 

1. URL_REGEXP only recognizes URLs at the start of a string, which is correct for is_url, but for calc_expected_status_length, all URLs should be detected, not just URLs at the start of the tweet. There should be a different URL_REGEXP for calc_expected_status_length without the start-of-string makers.
2. The URL regex has multiple groups, so findall returns a list of tuples, not strings. If there are matches, replaced_chars = len(''.join(match)) crashes, it should be replaced_chars = len(''.join(map(lambda x: x[0], match))) instead
diff --git a/tests/test_twitter_utils.py b/tests/test_twitter_utils.py
index 3ca619f..b021e34 100644
--- a/tests/test_twitter_utils.py
+++ b/tests/test_twitter_utils.py
@@ -5,6 +5,7 @@ import unittest
 import twitter
 
 from twitter.twitter_utils import (
+    calc_expected_status_length,
     parse_media_file
 )
 
@@ -58,3 +59,18 @@ class ApiTest(unittest.TestCase):
         self.assertRaises(
             twitter.TwitterError,
             lambda: twitter.twitter_utils.enf_type('test', int, 'hi'))
+
+    def test_calc_expected_status_length(self):
+        status = 'hi a tweet there'
+        len_status = calc_expected_status_length(status)
+        self.assertEqual(len_status, 16)
+
+    def test_calc_expected_status_length_with_url(self):
+        status = 'hi a tweet there example.com'
+        len_status = calc_expected_status_length(status)
+        self.assertEqual(len_status, 40)
+
+    def test_calc_expected_status_length_with_url_and_extra_spaces(self):
+        status = 'hi a tweet          there               example.com'
+        len_status = calc_expected_status_length(status)
+        self.assertEqual(len_status, 63)

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov
3.9
requirements.txt requirements.testing.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
build==1.2.2.post1
cachetools==5.5.2
certifi==2025.1.31
chardet==5.2.0
charset-normalizer==3.4.1
check-manifest==0.50
codecov==2.1.13
colorama==0.4.6
coverage==7.8.0
coveralls==4.0.1
distlib==0.3.9
docopt==0.6.2
exceptiongroup==1.2.2
filelock==3.18.0
future==1.0.0
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.1.0
mccabe==0.7.0
mock==5.2.0
oauthlib==3.2.2
packaging==24.2
platformdirs==4.3.7
pluggy==1.5.0
pycodestyle==2.13.0
pyproject-api==1.9.0
pyproject_hooks==1.2.0
pytest==8.3.5
pytest-cov==6.0.0
pytest-runner==6.0.1
-e git+https://github.com/bear/python-twitter.git@ae88240b902d857ba099dfd17f820e640c67557d#egg=python_twitter
PyYAML==6.0.2
requests==2.32.3
requests-oauthlib==2.0.0
responses==0.25.7
six==1.17.0
tomli==2.2.1
tox==4.25.0
tox-pyenv==1.1.0
typing_extensions==4.13.0
urllib3==2.3.0
virtualenv==20.30.0
zipp==3.21.0

name: python-twitter
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
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - 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=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - build==1.2.2.post1
      - cachetools==5.5.2
      - certifi==2025.1.31
      - chardet==5.2.0
      - charset-normalizer==3.4.1
      - check-manifest==0.50
      - codecov==2.1.13
      - colorama==0.4.6
      - coverage==7.8.0
      - coveralls==4.0.1
      - distlib==0.3.9
      - docopt==0.6.2
      - exceptiongroup==1.2.2
      - filelock==3.18.0
      - future==1.0.0
      - idna==3.10
      - importlib-metadata==8.6.1
      - iniconfig==2.1.0
      - mccabe==0.7.0
      - mock==5.2.0
      - oauthlib==3.2.2
      - packaging==24.2
      - platformdirs==4.3.7
      - pluggy==1.5.0
      - pycodestyle==2.13.0
      - pyproject-api==1.9.0
      - pyproject-hooks==1.2.0
      - pytest==8.3.5
      - pytest-cov==6.0.0
      - pytest-runner==6.0.1
      - pyyaml==6.0.2
      - requests==2.32.3
      - requests-oauthlib==2.0.0
      - responses==0.25.7
      - six==1.17.0
      - tomli==2.2.1
      - tox==4.25.0
      - tox-pyenv==1.1.0
      - typing-extensions==4.13.0
      - urllib3==2.3.0
      - virtualenv==20.30.0
      - zipp==3.21.0
prefix: /opt/conda/envs/python-twitter

tests/test_twitter_utils.py::ApiTest::test_calc_expected_status_length_with_url tests/test_twitter_utils.py::ApiTest::test_calc_expected_status_length_with_url_and_extra_spaces
tests/test_twitter_utils.py::ApiTest::test_calc_expected_status_length tests/test_twitter_utils.py::ApiTest::test_parse_media_file_fileobj tests/test_twitter_utils.py::ApiTest::test_parse_media_file_http tests/test_twitter_utils.py::ApiTest::test_parse_media_file_local_file tests/test_twitter_utils.py::ApiTest::test_utils_error_checking
twitter/__init__.py twitter/twitter_utils.py
twitter/__init__.py twitter/twitter_utils.py