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

ansible_mitogen: Some modules use from __future__ import unicode_literals #1228

Open
moreati opened this issue Jan 27, 2025 · 3 comments
Open
Labels
affects-0.3 Issues related to 0.3.X Mitogen releases bug Code feature that hinders desired execution outcome python2

Comments

@moreati
Copy link
Member

moreati commented Jan 27, 2025

On Python 3 this has no effect. On Python 2 it is probably causing some subtle bugs. Particularly if there's a mix of Python 2 and Python 3 on controller and targets.

$ ag unicode_literal mitogen/ ansible_mitogen tests -l | sort
ansible_mitogen/_trace.py
ansible_mitogen/connection.py
ansible_mitogen/module_finder.py
ansible_mitogen/parsing.py
ansible_mitogen/planner.py
ansible_mitogen/plugins/action/mitogen_get_stack.py
ansible_mitogen/services.py
ansible_mitogen/transport_config.py
tests/ansible/lib/callback/nice_stdout.py
tests/data/importer/webproject/webapp/apps.py
tests/data/importer/webproject/webapp/models.py
@moreati moreati added affects-0.3 Issues related to 0.3.X Mitogen releases bug Code feature that hinders desired execution outcome labels Jan 27, 2025
@moreati moreati changed the title ansible_mitogen: Several modules use from __future__ import unicode_literals ansible_mitogen: Some modules use from __future__ import unicode_literals Jan 27, 2025
@moreati
Copy link
Member Author

moreati commented Jan 27, 2025

To avoid confusion, we recommend using unicode_literals everywhere across a code-base or not at all, instead of turning on for only some modules.

-- https://python-future.org/unicode_literals.html

@moreati
Copy link
Member Author

moreati commented Jan 27, 2025

builtin:

myenum = type('Enum', (), enum)

(slightly esotic) doesn't work with unicode_literals: type() expects a string.

-- https://stackoverflow.com/questions/809796/any-gotchas-using-unicode-literals-in-python-2-6

@moreati
Copy link
Member Author

moreati commented Jan 27, 2025

I am beginning to think that from __future__ import unicode_literals does more harm than good. I don't recall exactly why we introduced it, but with the restoration of u"" literals in Python 3.3 we have a much better story for writing straddling code that is unicode-correct.
...
I wonder if we can add an official note to the 2.7 docs recommending against it?
-- GvR, https://mail.python.org/pipermail/python-dev/2016-December/147009.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-0.3 Issues related to 0.3.X Mitogen releases bug Code feature that hinders desired execution outcome python2
Projects
None yet
Development

No branches or pull requests

1 participant