1.2.0: F811 when importing os/os.path

Bug #1578051 reported by Florian Bruhin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pyflakes
Fix Released
Undecided
John Vandenberg

Bug Description

Since pyflakes 1.2.0, running it over this file:

    import os.path
    import os
    assert os

produces:

    x.py:2: redefinition of unused 'os' from line 1

Switching the order of the imports works around the issue, but I think this shouldn't be an error.

Revision history for this message
John Vandenberg (jayvdb) wrote :

Very likely to be a bug in my patch, which was supposed to have zero effect, except for improving the error messages, but it looks like this scenario wasnt covered in the tests (the inverse scenario was covered, as you've found).

https://github.com/pyflakes/pyflakes/commit/aec68a7847d8dbd1371242f42f9302103a68178f

Revision history for this message
John Vandenberg (jayvdb) wrote :

The simple fix for that specific problem is https://github.com/jayvdb/pyflakes/commit/2ba836ad18168b9ba3f0d53273da217a9e4d1bb9
Build OK at https://travis-ci.org/jayvdb/pyflakes/builds/127720312

Feel free to pull it in and release a bug fix release if this is a serious problem.

However I would like a few more hours to dig further, to ensure there are no other corner cases.

fwiw, I believe there is an lp bug asking that both of these are an error, as `os.path` is unused, even though `os` is used. Need to find that bug also.

Revision history for this message
Florian Bruhin (the-compiler) wrote :

Thanks for the quick fix! I'm okay with waiting a bit for a patch release, I just blacklisted 1.2.0 for now :)

> fwiw, I believe there is an lp bug asking that both of these are an error, as `os.path` is unused, even though `os` is used. Need to find that bug also.

Good point, though that was just an oversight in my example - my real code where I noticed this uses both os and os.path.

Revision history for this message
John Vandenberg (jayvdb) wrote :
Revision history for this message
John Vandenberg (jayvdb) wrote :

Released as 1.2.1

Changed in pyflakes:
assignee: nobody → John Vandenberg (jayvdb)
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.