Skip to content

Fix testing with tests.py on Py3.6. #8281

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

Merged
merged 1 commit into from
Mar 19, 2017

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Mar 13, 2017

Invoking tests.py used to fail on Py3.6 due to the use of deprecated
invalid escapes both in the codebase and in third-party code (dateutil).
Fix the codebase, skip the checks on dateutil.

It is strange (and should be worth investigating...) that the CI did not
fail before, as it also uses tests.py on Py3.6...

xref #8271.

Invoking `tests.py` used to fail on Py3.6 due to the use of deprecated
invalid escapes both in the codebase and in third-party code (dateutil).
Fix the codebase, skip the checks on dateutil.

It is strange (and should be worth investigating...) that the CI did not
fail before, as it also uses `tests.py` on Py3.6...
@tacaswell
Copy link
Member

I have also not been seeing these failures, and have been testing using tests.py + py3.6 for a while now...

@@ -94,12 +94,6 @@ def test_too_many_date_ticks():
# setting equal datetimes triggers and expander call in
# transforms.nonsingular which results in too many ticks in the
# DayLocator. This should trigger a Locator.MAXTICKS RuntimeError
warnings.filterwarnings(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this warning not come out of singular dates anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope (that's why the tests pass :-)).

@anntzer
Copy link
Contributor Author

anntzer commented Mar 13, 2017

Do you get a warning if you do $ python -Wd -c 'import dateutil.parser'?

Do you get an error on one of the escape sequences I fixed if you install the filter as in tests.py and import matplotlib in an interactive session?

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Mar 13, 2017
@dstansby
Copy link
Member

I can confirm that on a fresh install of python 3.6 there are a lot of escaped characters errors, which are fixed by this PR.

@tacaswell
Copy link
Member

with arch system python:

15:37 $ python
Python 3.6.0 (default, Jan 16 2017, 12:12:55) 
[GCC 6.3.1 20170109] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dateutil.parser
>>> import dateutil
>>> dateutil.__version__
'2.6.0'
>>> 

and python -Wd -c 'import dateutil.parser' does not raise. I am greatly confused by this whole thing...

@anntzer
Copy link
Contributor Author

anntzer commented Mar 14, 2017

woot

$ pacman -Q python{,-dateutil}          
python 3.6.0-2
python-dateutil 2.6.0-2
$ which python && python -minspect -d dateutil.parser
/usr/bin/python
Target: dateutil.parser
Origin: /usr/lib/python3.6/site-packages/dateutil/parser.py
Cached: /usr/lib/python3.6/site-packages/dateutil/__pycache__/parser.cpython-36.pyc
Loader: <_frozen_importlib_external.SourceFileLoader object at 0x7f6c5b71b278>
$ python -Wd -c 'import dateutil.parser'
/usr/lib/python3.6/site-packages/dateutil/parser.py:50: DeprecationWarning: invalid escape sequence \.
  _split_decimal = re.compile("([\.,])")

@tacaswell
Copy link
Member

16:02 $ pacman -Q python{,-dateutil}
python 3.6.0-2
python-dateutil 2.6.0-2
✔ ~ 
16:02 $ which python && python -minspect -d dateutil.parser
/usr/bin/python
Target: dateutil.parser
Origin: /usr/lib/python3.6/site-packages/dateutil/parser.py
Cached: /usr/lib/python3.6/site-packages/dateutil/__pycache__/parser.cpython-36.pyc
Loader: <_frozen_importlib_external.SourceFileLoader object at 0x7f046b1672e8>


✔ ~ 
16:02 $ python -Wd -c 'import dateutil.parser'
✔ ~ 
16:02 $ 

I am even more confused now...

@anntzer
Copy link
Contributor Author

anntzer commented Mar 14, 2017

$ md5sum /var/cache/pacman/pkg/python-3.6.0-2-x86_64.pkg.tar.xz  
931e87301d4c750a5bd66ff3507da484  /var/cache/pacman/pkg/python-3.6.0-2-x86_64.pkg.tar.xz
$ md5sum /var/cache/pacman/pkg/python-dateutil-2.6.0-2-any.pkg.tar.xz 
d4a81b5b18cf55bf4949a7b7be57f12c  /var/cache/pacman/pkg/python-dateutil-2.6.0-2-any.pkg.tar.xz

@tacaswell
Copy link
Member

16:04 $ md5sum /var/cache/pacman/pkg/python-3.6.0-2-x86_64.pkg.tar.xz                                                                                                                                                                                                                                                                                                                                                                   
931e87301d4c750a5bd66ff3507da484  /var/cache/pacman/pkg/python-3.6.0-2-x86_64.pkg.tar.xz                                                                                                                                                                                                                                                                                                                                                
✔ ~                                                                                                                                                                                                                                                                                                                                                                                                                                     
16:10 $ md5sum /var/cache/pacman/pkg/python-dateutil-2.6.0-2-any.pkg.tar.xz                                                                                                                                                                                                                                                                                                                                                             
d4a81b5b18cf55bf4949a7b7be57f12c  /var/cache/pacman/pkg/python-dateutil-2.6.0-2-any.pkg.tar.xz                                                                                                                                                                                                                                                                                                                                          
✔ ~                                                                                                                                                                                                                                                                                                                                                                                                                                     
16:10 $                                                                                                                                                                                                                                                                                                                                                                                                                                 

@anntzer
Copy link
Contributor Author

anntzer commented Mar 14, 2017

Anything in env | grep '^PYTHON'?

@tacaswell
Copy link
Member

Nope, I can get the warning via:

16:19 $ python -Wd
Python 3.6.0 (default, Jan 16 2017, 12:12:55) 
[GCC 6.3.1 20170109] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dateutil.parser
>>> s = '\['
<stdin>:1: DeprecationWarning: invalid escape sequence \[
>>> 

@anntzer
Copy link
Contributor Author

anntzer commented Mar 14, 2017

Ah, I found it.

If you do e.g. sudo touch /usr/lib/python3.6/site-packages/dateutil/parser.py, you will see the warning. (rather, I probably sudo-edited that file at some point just to quickly check on #8271, which changed the mtime, even though I later reverted the change). On the other hand, after I reinstall dateutil using sudo pacman -S --asdeps python-dateutil, the warning goes away.

I guess this is because the warning is only triggered at byte-compilation time, which only occurs if the mtime of the .py is more recent than the mtime of the .pyc -- which is not the case when you install from the package manager, but is the case after my change (and then it was always going to stay like that, as python did not have the rights to rewrite the pyc, so it had to re-byte-compile every time).

@tacaswell
Copy link
Member

That does make sense. It is re-assuring that the interpreter is, as usual, correct.

@@ -14,15 +14,16 @@

if __name__ == '__main__':

import dateutil.parser
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good to get rid of these in Matplotlib itself, but it's hacks like these that make me a bit wary to keep this test setup around. Maybe when we figure out the cron jobs, we can run this on a nightly build or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I think this test really belongs in something like pycodestyle.

@anntzer anntzer changed the title Fix testing with tests.py on Py3.6. [MRG] Fix testing with tests.py on Py3.6. Mar 15, 2017
@NelleV NelleV changed the title [MRG] Fix testing with tests.py on Py3.6. [MRG+1] Fix testing with tests.py on Py3.6. Mar 16, 2017
@QuLogic QuLogic changed the title [MRG+1] Fix testing with tests.py on Py3.6. Fix testing with tests.py on Py3.6. Mar 19, 2017
@QuLogic QuLogic merged commit c59edad into matplotlib:master Mar 19, 2017
@anntzer anntzer deleted the fix-deprecated-syntax-py36 branch March 19, 2017 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants