AttributeError in a Turkish locale

Bug #942603 reported by Marius Gedminas
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Pyflakes
Fix Released
Low
Unassigned

Bug Description

A user came into the #vim channel on IRC looking for help with the pyflakes plugin. I tracked down the error to a bug(?) in pyflakes: it doesn't work in a Turkish locale. Instead you get

AttributeError: 'Checker' object has no attribute 'ATTRiBUTE'

Screenshot of the original error: http://i.imgur.com/gAfRB.png

The user's locale:
LANG=tr_TR.UTF-8
LANGUAGE=
LC_CTYPE="tr_TR.UTF-8"
LC_NUMERIC="tr_TR.UTF-8"
LC_TIME="tr_TR.UTF-8"
LC_COLLATE="tr_TR.UTF-8"
LC_MONETARY="tr_TR.UTF-8"
LC_MESSAGES="tr_TR.UTF-8"
LC_PAPER="tr_TR.UTF-8"
LC_NAME="tr_TR.UTF-8"
LC_ADDRESS="tr_TR.UTF-8"
LC_TELEPHONE="tr_TR.UTF-8"
LC_MEASUREMENT="tr_TR.UTF-8"
LC_IDENTIFICATION="tr_TR.UTF-8"
LC_ALL=

This workaround fixed the error for that user:

<mgedmin> edit that pyflakes/checker.py file, find line 317 (actual number might differ depending on the version) -- the line that does 'nodeType = node.__class__.__name__.upper()'
<mgedmin> change it to 'nodeType = node.__class__.__name__.upper().replace("i", "I")'

Revision history for this message
Orcun Avsar (orc-avs) wrote :

That bothered me, too. This happens resulting from a well-known problem for Turkish locale. Lower 'i' stays as 'i' on upper() function, so 'assign' becomes 'ASSiGN' instead of 'ASSIGN' and that causes further error when getattr(node, 'ASSiGN') is called. I don't know what upper() is used for. But you should either accept this workaround or use locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') at the top of the code somewhere as upper() and lower() functions are locale-dependent.

Florent (florent.x)
Changed in pyflakes:
status: New → Confirmed
Revision history for this message
Florent (florent.x) wrote :

Committed on trunk, rev 77

Changed in pyflakes:
importance: Undecided → Low
status: Confirmed → Fix Committed
Florent (florent.x)
Changed in pyflakes:
milestone: none → 0.7
Florent (florent.x)
Changed in pyflakes:
status: Fix Committed → 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.