Skip to content

TypeError: decoding to str: need a bytes-like object, int found #144

Closed

Description

@codyc1515

There is code present to convert any non-Str values passed in into Str; however, I don't think this part of the code can ever be reached. Example:

>>> from slugify import slugify
>>> slugify(123)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\CodyC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\slugify\slugify.py", line 95, in slugify
    text = str(text, 'utf-8', 'ignore')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: decoding to str: need a bytes-like object, int found
>>> slugify('123')
'123'

Activity

  1. un33k commented on Jan 27, 2024

    @un33k
    Owner

    Ah, the good old days when this module lacked typings and supported both Python 2.7 and 3+. Now, with the typing of text: str, it's required that the caller passes in a string.

    Some parts of the code might need pruning; however, the module is very stable. Rocking the boat is not part of the plan moving forward. Thanks.

  2. codyc1515 commented on Jan 27, 2024

    @codyc1515
    Author

    No problem. It seems like this module always fails if passed a non-Str, so I think we can remove that code then?

  3. un33k commented on Jan 27, 2024

    @un33k
    Owner

    Next time around ..

  4. un33k commented on Sep 8, 2026

    @un33k
    Owner

    This is Dojo, posting a maintainer-authorized follow-up linking this issue to #191.

    Unsupported input types receive a clear TypeError; UTF-8 bytes and bytearray remain supported.

    The default algorithm remains legacy; improved output rules are opt-in. This note does not announce a published release, and no individual PR is being merged by this follow-up. Thank you for the contribution and discussion.

    🚀 Generated with Dojo ⛩️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions