malefice: @fcurella Based on the error logs, it appears that the docker image's locale has not been set to something that supports `UTF-8`. To verify, I tried to replicate the environment by setting up an `i386/ubuntu` docker image, installed `locales`, and then ran the command `locale-gen en_US.UTF-8`. When I checked the default locale, none was set.

```
root@4cf92a376f00:/# cat /etc/default/locale
#  File generated by update-locale
```

The `build32bit.sh` file needs to be updated to set the locale manually. Try appending the command `update-locale LANG=en_US.UTF-8` after the `locale-gen` command.

malefice: @fcurella @OJFord So, I finally got the time to set up travis for my fork. I applied my recommendations on top of the work done in this pull request, and the 32bit build passes. You can see it [here](https://travis-ci.com/malefice/faker/builds/136106896).

Just add `export LANG='en_US.UTF-8' in `build32bit.sh` as shown [here](https://github.com/malefice/faker/blob/89584bcc8cfb5db8ef00975ae083bf7b7b210534/build32bit.sh#L13).
fcurella: Thank @malefice, I've committed the fix to master.

@OJFord could you rebase your branch against `master`?
diff --git a/faker/providers/date_time/__init__.py b/faker/providers/date_time/__init__.py
index 39dab838..529db175 100644
--- a/faker/providers/date_time/__init__.py
+++ b/faker/providers/date_time/__init__.py
@@ -4,7 +4,7 @@ from calendar import timegm
 from datetime import MAXYEAR, timedelta
 
 from dateutil import relativedelta
-from dateutil.tz import tzlocal, tzutc
+from dateutil.tz import gettz, tzlocal, tzutc
 
 from faker.utils.datetime_safe import date, datetime, real_date, real_datetime
 
@@ -1962,6 +1962,17 @@ class Provider(BaseProvider):
         return self.generator.random.choice(
             self.random_element(self.countries)['timezones'])
 
+    def pytimezone(self, *args, **kwargs):
+        """
+        Generate a random timezone (see `faker.timezone` for any args)
+        and return as a python object usable as a `tzinfo` to `datetime`
+        or other fakers.
+
+        :example faker.pytimezone()
+        :return dateutil.tz.tz.tzfile
+        """
+        return gettz(self.timezone(*args, **kwargs))
+
     def date_of_birth(self, tzinfo=None, minimum_age=0, maximum_age=115):
         """
         Generate a random date of birth represented as a Date object,

suggestion: pytimezone
In addition to the currently available [timezone](), it would be very useful* to have a similar python object faker, something like:
```python
import pytz

class TheExistingPythonProvider:

    def pytimezone(self, **kwargs):
        return pytz.timezone(self.generator.timezone(**kwargs))
```

For an example use-case, see:

\* FactoryBoy/factory_boy#643
diff --git a/tests/providers/test_date_time.py b/tests/providers/test_date_time.py
index 30e9cf09..ad951a5f 100644
--- a/tests/providers/test_date_time.py
+++ b/tests/providers/test_date_time.py
@@ -138,6 +138,16 @@ class TestDateTime(unittest.TestCase):
         today_back = datetime.fromtimestamp(timestamp, utc).date()
         assert today == today_back
 
+    def test_pytimezone(self):
+        import dateutil
+        pytz = self.fake.pytimezone()
+        assert isinstance(pytz, dateutil.tz.tz.tzfile)
+
+    def test_pytimezone_usable(self):
+        pytz = self.fake.pytimezone()
+        date = datetime(2000, 1, 1, tzinfo=pytz)
+        assert date.tzinfo == pytz
+
     def test_datetime_safe(self):
         from faker.utils import datetime_safe
         # test using example provided in module

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest coverage freezegun random2 ukpostcodeparser validators
apt-get update apt-get install -y gcc
3.9
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
coverage==7.8.0
exceptiongroup==1.2.2
-e git+https://github.com/joke2k/faker.git@46450c265271029b6cf0c5fa3c5c2e0d4508ca27#egg=Faker
freezegun==1.5.1
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
python-dateutil==2.9.0.post0
random2==1.0.2
six==1.17.0
text-unidecode==1.3
tomli==2.2.1
UkPostcodeParser==1.1.2
validators==0.34.0

name: faker
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:
      - coverage==7.8.0
      - exceptiongroup==1.2.2
      - freezegun==1.5.1
      - iniconfig==2.1.0
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - python-dateutil==2.9.0.post0
      - random2==1.0.2
      - six==1.17.0
      - text-unidecode==1.3
      - tomli==2.2.1
      - ukpostcodeparser==1.1.2
      - validators==0.34.0
prefix: /opt/conda/envs/faker

tests/providers/test_date_time.py::TestDateTime::test_pytimezone tests/providers/test_date_time.py::TestDateTime::test_pytimezone_usable
tests/providers/test_date_time.py::TestKoKR::test_day tests/providers/test_date_time.py::TestKoKR::test_month tests/providers/test_date_time.py::TestDateTime::test_date_between tests/providers/test_date_time.py::TestDateTime::test_date_between_dates tests/providers/test_date_time.py::TestDateTime::test_date_between_months tests/providers/test_date_time.py::TestDateTime::test_date_object tests/providers/test_date_time.py::TestDateTime::test_date_this_period tests/providers/test_date_time.py::TestDateTime::test_date_time_between tests/providers/test_date_time.py::TestDateTime::test_date_time_between_dates tests/providers/test_date_time.py::TestDateTime::test_date_time_between_dates_with_tzinfo tests/providers/test_date_time.py::TestDateTime::test_date_time_this_period tests/providers/test_date_time.py::TestDateTime::test_date_time_this_period_with_tzinfo tests/providers/test_date_time.py::TestDateTime::test_datetime_safe tests/providers/test_date_time.py::TestDateTime::test_datetime_safe_new_date tests/providers/test_date_time.py::TestDateTime::test_datetimes_with_and_without_tzinfo tests/providers/test_date_time.py::TestDateTime::test_day tests/providers/test_date_time.py::TestDateTime::test_future_date tests/providers/test_date_time.py::TestDateTime::test_future_datetime tests/providers/test_date_time.py::TestDateTime::test_month tests/providers/test_date_time.py::TestDateTime::test_parse_date tests/providers/test_date_time.py::TestDateTime::test_parse_date_time tests/providers/test_date_time.py::TestDateTime::test_parse_timedelta tests/providers/test_date_time.py::TestDateTime::test_past_date tests/providers/test_date_time.py::TestDateTime::test_past_datetime tests/providers/test_date_time.py::TestDateTime::test_past_datetime_within_second tests/providers/test_date_time.py::TestDateTime::test_time_object tests/providers/test_date_time.py::TestDateTime::test_time_series tests/providers/test_date_time.py::TestDateTime::test_timedelta tests/providers/test_date_time.py::TestDateTime::test_timezone_conversion tests/providers/test_date_time.py::TestDateTime::test_unix_time tests/providers/test_date_time.py::TestPlPL::test_day tests/providers/test_date_time.py::TestPlPL::test_month tests/providers/test_date_time.py::TestHyAm::test_day tests/providers/test_date_time.py::TestHyAm::test_month tests/providers/test_date_time.py::TestAr::test_ar_aa tests/providers/test_date_time.py::TestAr::test_ar_eg tests/providers/test_date_time.py::DatesOfBirth::test_acceptable_age_range_eighteen_years tests/providers/test_date_time.py::DatesOfBirth::test_acceptable_age_range_five_years tests/providers/test_date_time.py::DatesOfBirth::test_bad_age_range tests/providers/test_date_time.py::DatesOfBirth::test_date_of_birth tests/providers/test_date_time.py::DatesOfBirth::test_distant_age_range tests/providers/test_date_time.py::DatesOfBirth::test_identical_age_range tests/providers/test_date_time.py::DatesOfBirth::test_type_errors tests/providers/test_date_time.py::DatesOfBirth::test_value_errors tests/providers/test_date_time.py::TestFilPh::test_PH_month_name tests/providers/test_date_time.py::TestFilPh::test_PH_of_week tests/providers/test_date_time.py::TestTlPh::test_PH_month_name tests/providers/test_date_time.py::TestTlPh::test_PH_of_week tests/providers/test_date_time.py::TestTaIN::test_day tests/providers/test_date_time.py::TestTaIN::test_month tests/providers/test_date_time.py::TestRuRu::test_day tests/providers/test_date_time.py::TestRuRu::test_month tests/providers/test_date_time.py::TestRuRu::test_timezone
faker/providers/date_time/__init__.py
faker/providers/date_time/__init__.py