Patch for cups.py to warn about dangerous LC_CTYPE
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
HPLIP |
New
|
Undecided
|
Unassigned |
Bug Description
Please apply the attached patch to prnt/cups.py.
It is very simple:
if current_ctype is not None:
+ #### Note: if does not help to set LC_CTYPE to C above (from
+ #### newctype). This setting here matters.
+ if len(current_ctype) > 0 and current_ctype != "C":
+ log.warn("LC_CTYPE is " + current_ctype + ". If a PPD file cannot be found: cancel, unset your LC_CTYPE environment variable, and rerun.")
It adds a warning if LC_CTYPE is set to anything other than C. With LC_CTYPE set to en_US, at least, hp-setup is not able to find the PPD file for a Photosmart C7280. With this patch, I get a useful warning from both hp-check and hp-setup. Without it, this problem is difficult to track down. See, for example,
https:/
https:/
I expect this this problem has caused grief for many, many other people.
The patch also includes a comment noting that attempting to set LC_CTYPE to C prior to the "import cupsext" doesn't solve the problem.
An alternative approach to solving this problem might be to replace the warning with a hard-coded assignment of LC_CTYPE to C here. I don't know if that is a good idea or not.
Here is how I tested this patch:
# cd /usr/share/hplip/ #### Where the prnt/ directory containing cups.py* is located.
# patch < /tmp/cups.py.diff
# env -i PYTHONPATH=. python -i cups.py
# env -i PYTHONPATH=. python -i -O cups.py
$ LC_CTYPE=en_US hp-check #### Triggers the warning.
$ LC_CTYPE=en_US hp-setup #### Triggers the warning.
$ LC_CTYPE= hp-setup #### Allows successful setup!
description: | updated |
I'm not sure how to determine which locales cause a problem. These do for me: de_DE, en_US, en_GB, en_CA, and pl_PL. So it seems to me that anything other than C should trigger the warning, but you may know better.