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

Add documentation about python3 compatibility #89

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
4 participants
@claudep
Copy link
Member

commented May 23, 2012

No description provided.

del frame
elif locs is None:
locs = globs
exec("""exec code in globs, locs""")

This comment has been minimized.

Copy link
@alex

alex May 23, 2012

Member

Is exec actually used anywhere besides in this file?

This comment has been minimized.

Copy link
@claudep

claudep May 24, 2012

Author Member

AFAIK, it's only used for the reraise definition just below. You can find the exact same code in six: https://bitbucket.org/gutworth/six/src/175a03e21623/six.py#cl-294

This comment has been minimized.

Copy link
@alex

alex May 24, 2012

Member

If we don't actually need exec for django why don't we simplify this implementation and give it some name so it won't be public (e.g. _exec).

This comment has been minimized.

Copy link
@claudep

claudep May 24, 2012

Author Member

Feel free to suggest any improvement/simplification. I see now that Vinay used it once in his branch in _doctest.py. I have chosen another route for updating _doctest.py and propose to copy python 3.2 doctest.py in _doctest3.py, reapply Python #1521051 on it and import conditionally _doctest.py/_doctest3.py. It's difficult for me to evaluate if this function might be useful or not in Django apps ecosystem.

# Do stuff Python 3-wise
else:
# Do stuff Python 2-wise

This comment has been minimized.

Copy link
@alex

alex May 23, 2012

Member

This section should probably note that using the various variables in the py3 module is preferrable to branching on if PY3

This comment has been minimized.

Copy link
@claudep

claudep May 24, 2012

Author Member

Good suggestion. Something like: "This should be considered as a last resort solution when it is not possible to import a compatible name from django.utils.py3."

No more long type
-----------------
``long`` and ``int`` types have been unified in Python 3, meaning that ``long``
is no more available. ``django.utils.py3`` provides both ``long_type`` and

This comment has been minimized.

Copy link
@kezabelle

kezabelle May 24, 2012

Contributor

"no more available" doesn't read particularly well, it'd be better to say something like "no longer available", but I'm not enthused with that either because it seems accidentally punny.

exec_ = getattr(builtins, 'exec')
def with_metaclass(meta, base=object):
ns = dict(base=base, meta=meta)
exec_("""class _DjangoBase(base, metaclass=meta):

This comment has been minimized.

Copy link
@YorikSar

YorikSar May 29, 2012

Why use exec? You can just write contents of the string in the function.

exec("""exec code in globs, locs""")
exec_("""def reraise(tp, value, tb=None):
raise tp, value, tb
""")

This comment has been minimized.

Copy link
@YorikSar

YorikSar May 29, 2012

Once again, exec is not needed here.

@claudep

This comment has been minimized.

Copy link
Member Author

commented Jun 7, 2012

Pushed in 5e6ded2.
Thanks for the review. I'm not sure if I included all what you meant in the review comments, feel free to open tickets to fix unsolved issues or to add further improvements.

@claudep claudep closed this Jun 7, 2012

sztrovacsek pushed a commit to sztrovacsek/django that referenced this pull request Mar 7, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.