Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
codyc1515 opened this issue Jan 27, 2024 · 3 comments
Closed

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

codyc1515 opened this issue Jan 27, 2024 · 3 comments

Comments

@codyc1515
Copy link

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'
@un33k
Copy link
Owner

un33k commented Jan 27, 2024

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.

@codyc1515
Copy link
Author

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

@un33k
Copy link
Owner

un33k commented Jan 27, 2024

Next time around ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants