Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 583FD200C13 for ; Mon, 6 Feb 2017 13:36:46 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 5500A160B53; Mon, 6 Feb 2017 12:36:46 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9BB13160B49 for ; Mon, 6 Feb 2017 13:36:45 +0100 (CET) Received: (qmail 82030 invoked by uid 500); 6 Feb 2017 12:36:44 -0000 Mailing-List: contact commits-help@airflow.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airflow.incubator.apache.org Delivered-To: mailing list commits@airflow.incubator.apache.org Received: (qmail 82021 invoked by uid 99); 6 Feb 2017 12:36:44 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Feb 2017 12:36:44 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 639171A00F4 for ; Mon, 6 Feb 2017 12:36:44 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.999 X-Spam-Level: X-Spam-Status: No, score=-1.999 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id Sd8khc4Vye5n for ; Mon, 6 Feb 2017 12:36:43 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id F10E35FE1E for ; Mon, 6 Feb 2017 12:36:42 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 4769EE02EF for ; Mon, 6 Feb 2017 12:36:42 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id B09C124D30 for ; Mon, 6 Feb 2017 12:36:41 +0000 (UTC) Date: Mon, 6 Feb 2017 12:36:41 +0000 (UTC) From: "Erik Cederstrand (JIRA)" To: commits@airflow.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (AIRFLOW-840) Python3 encoding issue in Kerberos MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 06 Feb 2017 12:36:46 -0000 [ https://issues.apache.org/jira/browse/AIRFLOW-840?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Erik Cederstrand updated AIRFLOW-840: ------------------------------------- Description: While attempting to configure Kerberos ticket renewal in a Python3 environment, I encountered this encoding issue trying to run {{airflow kerberos}}: {quote} Traceback (most recent call last): File "/usr/local/bin/airflow", line 15, in args.func(args) File "/usr/local/lib/python3.4/dist-packages/airflow/bin/cli.py", line 600, in kerberos airflow.security.kerberos.run() File "/usr/local/lib/python3.4/dist-packages/airflow/security/kerberos.py", line 110, in run renew_from_kt() File "/usr/local/lib/python3.4/dist-packages/airflow/security/kerberos.py", line 55, in renew_from_kt "\n".join(subp.stderr.readlines()))) TypeError: sequence item 0: expected str instance, bytes found {quote} The issue here (ignoring for a moment why {{kinit}} is failing on my machine) is that Popen in Python3 returns {{bytes}} for stdin/stdout, but both are handled as if they are {{str}}. I'm unsure what the Py2/3 compat policy is at Airflow, but a simple {{from six import PY2}} and an if/else seems like the least intrusive fix. The non-PY2 path would then add something like {{subp.stdin.readlines().decode(errors='ignore')}} was: While attempting to configure Kerberos ticket renewal in a Python3 environment, I encountered this encoding issue trying to run {{airflow kerberos}}: {{ Traceback (most recent call last): File "/usr/local/bin/airflow", line 15, in args.func(args) File "/usr/local/lib/python3.4/dist-packages/airflow/bin/cli.py", line 600, in kerberos airflow.security.kerberos.run() File "/usr/local/lib/python3.4/dist-packages/airflow/security/kerberos.py", line 110, in run renew_from_kt() File "/usr/local/lib/python3.4/dist-packages/airflow/security/kerberos.py", line 55, in renew_from_kt "\n".join(subp.stderr.readlines()))) TypeError: sequence item 0: expected str instance, bytes found }} The issue here (ignoring for a moment why {{kinit}} is failing on my machine) is that Popen in Python3 returns {{bytes}} for stdin/stdout, but both are handled as if they are {{str}}. I'm unsure what the Py2/3 compat policy is at Airflow, but a simple {{from six import PY2}} and an if/else seems like the least intrusive fix. The non-PY2 path would then add something like {{subp.stdin.readlines().decode(errors='ignore')}} > Python3 encoding issue in Kerberos > ---------------------------------- > > Key: AIRFLOW-840 > URL: https://issues.apache.org/jira/browse/AIRFLOW-840 > Project: Apache Airflow > Issue Type: Bug > Components: security > Affects Versions: Airflow 1.8 > Environment: $ python --version > Python 3.4.3 > Reporter: Erik Cederstrand > Labels: security > > While attempting to configure Kerberos ticket renewal in a Python3 environment, I encountered this encoding issue trying to run {{airflow kerberos}}: > {quote} > Traceback (most recent call last): > File "/usr/local/bin/airflow", line 15, in > args.func(args) > File "/usr/local/lib/python3.4/dist-packages/airflow/bin/cli.py", line 600, in kerberos > airflow.security.kerberos.run() > File "/usr/local/lib/python3.4/dist-packages/airflow/security/kerberos.py", line 110, in run > renew_from_kt() > File "/usr/local/lib/python3.4/dist-packages/airflow/security/kerberos.py", line 55, in renew_from_kt > "\n".join(subp.stderr.readlines()))) > TypeError: sequence item 0: expected str instance, bytes found > {quote} > The issue here (ignoring for a moment why {{kinit}} is failing on my machine) is that Popen in Python3 returns {{bytes}} for stdin/stdout, but both are handled as if they are {{str}}. > I'm unsure what the Py2/3 compat policy is at Airflow, but a simple {{from six import PY2}} and an if/else seems like the least intrusive fix. The non-PY2 path would then add something like {{subp.stdin.readlines().decode(errors='ignore')}} -- This message was sent by Atlassian JIRA (v6.3.15#6346)