Merge lp:~divmod-dev/divmod.org/windowserror-builtin into lp:divmod.org

Proposed by Jean-Paul Calderone
Status: Merged
Approved by: Tristan Seligmann
Approved revision: 2686
Merged at revision: 2688
Proposed branch: lp:~divmod-dev/divmod.org/windowserror-builtin
Merge into: lp:divmod.org
Diff against target: 34 lines (+11/-2)
2 files modified
Pyflakes/pyflakes/checker.py (+3/-2)
Pyflakes/pyflakes/test/test_undefined_names.py (+8/-0)
To merge this branch: bzr merge lp:~divmod-dev/divmod.org/windowserror-builtin
Reviewer Review Type Date Requested Status
Tristan Seligmann Approve
Jonathan Jacobs Approve
Review via email: mp+84407@code.launchpad.net

Description of the change

Change WindowsError to be treated as one of the magic builtins, so it is never warned as an undefined name.

To post a comment you must log in.
Revision history for this message
Jonathan Jacobs (jjacobs) wrote :

Horribleness magic globals aside, this looks good to merge.

review: Approve
Revision history for this message
Tristan Seligmann (mithrandi) wrote :

This renders the comment above the _MAGIC_GLOBALS definition slightly inaccurate; how about appending something like "or are only present on some platforms"?

review: Needs Fixing
2686. By Jean-Paul Calderone

Adjust the comment about _MAGIC_GLOBALS, explaining that it also papers over cross-platform __builtin__ differences.

Revision history for this message
Tristan Seligmann (mithrandi) wrote :

Looks good! (sorry for the latency in responding to this, Launchpad doesn't send notifications when a merge proposal's branch is updated, only when comments are made on the MP)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Pyflakes/pyflakes/checker.py'
2--- Pyflakes/pyflakes/checker.py 2011-11-17 16:21:58 +0000
3+++ Pyflakes/pyflakes/checker.py 2011-12-21 17:00:33 +0000
4@@ -173,8 +173,9 @@
5 pass
6
7
8-# Globally defined names which are not attributes of the __builtin__ module.
9-_MAGIC_GLOBALS = ['__file__', '__builtins__']
10+# Globally defined names which are not attributes of the __builtin__ module, or
11+# are only present on some platforms.
12+_MAGIC_GLOBALS = ['__file__', '__builtins__', 'WindowsError']
13
14
15
16
17=== modified file 'Pyflakes/pyflakes/test/test_undefined_names.py'
18--- Pyflakes/pyflakes/test/test_undefined_names.py 2010-04-13 14:53:04 +0000
19+++ Pyflakes/pyflakes/test/test_undefined_names.py 2011-12-21 17:00:33 +0000
20@@ -27,6 +27,14 @@
21 self.flakes('range(10)')
22
23
24+ def test_builtinWindowsError(self):
25+ """
26+ C{WindowsError} is sometimes a builtin name, so no warning is emitted
27+ for using it.
28+ """
29+ self.flakes('WindowsError')
30+
31+
32 def test_magicGlobalsFile(self):
33 """
34 Use of the C{__file__} magic global should not emit an undefined name

Subscribers

People subscribed via source and target branches

to all changes: