changeset 6:00d59dc616ba

FIX: Use "LC_PAPER" only on GNU Linux. It is a GNU extension to locale.
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 16 Sep 2025 14:38:35 +0200
parents d80ac90277ac
children c72344e5f707
files pdfautonup/options.py pdfautonup/paper.py
diffstat 2 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/pdfautonup/options.py	Tue Sep 16 13:56:37 2025 +0200
+++ b/pdfautonup/options.py	Tue Sep 16 14:38:35 2025 +0200
@@ -134,7 +134,7 @@
             Paper size is read from the following sources (in that order):
 
             - Argument of "--size" option;
-            - LC_PAPER environment variable (read as mm);
+            - LC_PAPER environment variable (GNU Linux only, read as mm);
             - PAPERSIZE environment variable;
             - content of file specified by the PAPERCONF environment variable;
             - content of file /etc/papersize;
--- a/pdfautonup/paper.py	Tue Sep 16 13:56:37 2025 +0200
+++ b/pdfautonup/paper.py	Tue Sep 16 14:38:35 2025 +0200
@@ -16,6 +16,7 @@
 """Paper-size related functions"""
 
 import os
+import platform
 import subprocess
 import typing
 from decimal import Decimal
@@ -55,13 +56,17 @@
             return papersize.parse_papersize(target_size)
         return target_size
 
-    # LC_PAPER environment variable (can be read from "locale -k LC_PAPER"
-    try:
-        return parse_lc_paper(
-            subprocess.check_output(["locale", "-k", "LC_PAPER"], text=True)
-        )
-    except (FileNotFoundError, subprocess.CalledProcessError, errors.CouldNotParse):
-        pass
+    if platform.system() in ("Linux", ):
+        #
+        # LC_PAPER environment variable (can be read from "locale -k LC_PAPER)"
+        # -- but only on GNU systems (it is a GNU extension).
+        #
+        try:
+            return parse_lc_paper(
+                subprocess.check_output(["locale", "-k", "LC_PAPER"], text=True)
+            )
+        except (FileNotFoundError, subprocess.CalledProcessError, errors.CouldNotParse):
+            pass
 
     # PAPERSIZE environment variable
     try: