AttributeError in a Turkish locale

Reported by Marius Gedminas on 2012-02-28
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Pyflakes
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")'

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) on 2013-03-30
Changed in pyflakes:
status: New → Confirmed
Florent (florent.x) wrote :

Committed on trunk, rev 77

Changed in pyflakes:
importance: Undecided → Low
status: Confirmed → Fix Committed
Florent (florent.x) on 2013-04-04
Changed in pyflakes:
milestone: none → 0.7
Florent (florent.x) on 2013-04-17
Changed in pyflakes:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers