[Bug 2018666] [NEW] AttributeError: module 'icu' has no attribute 'Locale'

Benjamin Drung 2018666 at bugs.launchpad.net
Sat May 6 22:42:09 UTC 2023


Public bug reported:

I stumbled over this crash during import while I was working on the
tzdata package update. How to reproduce: Install natsort, but do not
install the icu Python module. Create an empty directory called `icu`
and then try to import natsort:

```
$ sudo apt install python3-natsort
$ sudo apt remove python3-icu
$ mkdir icu
$ python3 -c "import natsort"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/natsort/__init__.py", line 3, in <module>
    from natsort.natsort import (
  File "/usr/lib/python3/dist-packages/natsort/natsort.py", line 846, in <module>
    os_sort_key = os_sort_keygen()
                  ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/natsort/natsort.py", line 814, in os_sort_keygen
    loc = natsort.compat.locale.get_icu_locale()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/natsort/compat/locale.py", line 42, in get_icu_locale
    return cast(str, icu.Locale(".".join(getlocale())))
                     ^^^^^^^^^^
AttributeError: module 'icu' has no attribute 'Locale'
```

ProblemType: Bug
DistroRelease: Ubuntu 23.04
Package: python3-natsort 8.0.2-2
ProcVersionSignature: Ubuntu 6.2.0-20.20-generic 6.2.6
Uname: Linux 6.2.0-20-generic x86_64
ApportVersion: 2.26.1-0ubuntu2
Architecture: amd64
CasperMD5CheckResult: pass
CurrentDesktop: ubuntu:GNOME
Date: Sun May  7 00:37:52 2023
Dependencies:
 
InstallationDate: Installed on 2022-03-09 (423 days ago)
InstallationMedia: Ubuntu 21.10 "Impish Indri" - Release amd64 (20211012)
PackageArchitecture: all
SourcePackage: natsort
UpgradeStatus: Upgraded to lunar on 2023-04-25 (11 days ago)

** Affects: natsort (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug lunar wayland-session

-- 
You received this bug notification because you are a member of Ubuntu
OpenStack, which is subscribed to natsort in Ubuntu.
https://bugs.launchpad.net/bugs/2018666

Title:
  AttributeError: module 'icu' has no attribute 'Locale'

Status in natsort package in Ubuntu:
  New

Bug description:
  I stumbled over this crash during import while I was working on the
  tzdata package update. How to reproduce: Install natsort, but do not
  install the icu Python module. Create an empty directory called `icu`
  and then try to import natsort:

  ```
  $ sudo apt install python3-natsort
  $ sudo apt remove python3-icu
  $ mkdir icu
  $ python3 -c "import natsort"
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/usr/lib/python3/dist-packages/natsort/__init__.py", line 3, in <module>
      from natsort.natsort import (
    File "/usr/lib/python3/dist-packages/natsort/natsort.py", line 846, in <module>
      os_sort_key = os_sort_keygen()
                    ^^^^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/natsort/natsort.py", line 814, in os_sort_keygen
      loc = natsort.compat.locale.get_icu_locale()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/natsort/compat/locale.py", line 42, in get_icu_locale
      return cast(str, icu.Locale(".".join(getlocale())))
                       ^^^^^^^^^^
  AttributeError: module 'icu' has no attribute 'Locale'
  ```

  ProblemType: Bug
  DistroRelease: Ubuntu 23.04
  Package: python3-natsort 8.0.2-2
  ProcVersionSignature: Ubuntu 6.2.0-20.20-generic 6.2.6
  Uname: Linux 6.2.0-20-generic x86_64
  ApportVersion: 2.26.1-0ubuntu2
  Architecture: amd64
  CasperMD5CheckResult: pass
  CurrentDesktop: ubuntu:GNOME
  Date: Sun May  7 00:37:52 2023
  Dependencies:
   
  InstallationDate: Installed on 2022-03-09 (423 days ago)
  InstallationMedia: Ubuntu 21.10 "Impish Indri" - Release amd64 (20211012)
  PackageArchitecture: all
  SourcePackage: natsort
  UpgradeStatus: Upgraded to lunar on 2023-04-25 (11 days ago)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/natsort/+bug/2018666/+subscriptions




More information about the Ubuntu-openstack-bugs mailing list