-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 an option to warn about Python 3.x possible incompatibilities #2191
Comments
there will be a path to it after we integrate warnings support its technically not possible to trigger -3 from entry-points as of now - so unless someone fixes that we simply cannot do |
I'm curious, is there a way to programmatically enable |
@nicoddemus |
That was my question, how to do it. 😁 I didn't see how after a quick look at the 2.7's docs. |
@nicoddemus uppon investigation, its disturbingly simple because the stdlib has an utterly hacky solution just set |
so we could actually support it just as a cli option |
Heh that's interesting. Yeah simple enough to support. We probably we should add it as an INI option, and users can use the new |
But the docs says:
see: https://docs.python.org/2/library/sys.html#sys.py3kwarning |
I'm not sure that is possible to fix then. |
@nicoddemus based on
on python 2 it should be possible to just set it and get agood deal out of it |
the option should named in a way that signifies we try and hack a readonly var |
I was looking around at the help wanted tags for a first contribution. So I started exploring this issue a little bit. I may be misunderstanding some of this discussion, as I am still not super familiar with the code base. However, I do not believe that setting sys.py3kwarning to True will be sufficient. I wrote a quick example: import sys
class CauseWarning(object):
def __eq__(self, other):
return self._foo == other._foo
if __name__ == '__main__':
print(sys.py3kwarning) when run with python2 and no -3 flag one gets:
which is expected when running with the -3 flag one gets:
also expected However, when you add in the line
but no warning. Please let me know if I am missing anything, but with some quick investigations, it appears setting sys.py3kwarning my not be sufficient. |
@rhuard I'm not sure, indeed it doesn't seem to be enough. To check if this was something that only takes effect if set before importing a module, I also tried to:
(where But this also doesn't produce any warning. |
@nicoddemus I was trying something similar with the python interactive interpreter: entering into interactive with
where test_warn.py is the code spinet I put up earlier. If you start interactive interpreter without the Since the docs say py3kwarning is read-only. I am thinking |
I see @rhuard, thanks for confirming. 👍 |
it seems we cant fix the python internals will close this one as wontfix |
@rhuard thanks for confirming |
Is it possible to enable "-3" by default?!?
The Python Interpreter parameter "-3" will warn about Python 3.x possible incompatibilities, see: https://docs.python.org/2/using/cmdline.html#cmdoption-3
Normally i just run pytest
To enable the warnings, i can run via python -3 -m pytest
The text was updated successfully, but these errors were encountered: