Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105681
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Zachary Ware <zachary.ware+pylist@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Problem With Embedded Icon and Python 3.4 |
| Date | Fri, 25 Mar 2016 00:34:13 -0500 |
| Lines | 60 |
| Sender | zachary.ware@gmail.com |
| Message-ID | <mailman.130.1458884075.2244.python-list@python.org> (permalink) |
| References | <Ju-dnWKBjbD8VWnLnZ2dnUU7-amdnZ2d@giganews.com> |
| Reply-To | python-list@python.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | news.uni-berlin.de j0TPLyTgO4k//E20OQGJuggjtpBGEbiRSfk2yepD/RnQ== |
| Return-Path | <zachary.ware@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'encoded': 0.05; 'error:': 0.05; 'constructor': 0.07; 'method,': 0.07; 'rewrite': 0.07; 'base64': 0.09; 'icon': 0.09; 'typeerror:': 0.09; 'received:209.85.218': 0.10; 'python': 0.10; '2.7': 0.13; 'argument': 0.15; 'encoding': 0.15; '"""\\': 0.16; "'b'": 0.16; '16x16': 0.16; '2016': 0.16; 'ascii,': 0.16; 'guess.': 0.16; 'least.': 0.16; 'literal,': 0.16; 'literal.': 0.16; 'means.': 0.16; 'png': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Problem': 0.16; 'wrote:': 0.16; 'string': 0.17; 'sender:addr:gmail.com': 0.18; 'byte': 0.18; 'bytes': 0.18; 'skip:` 10': 0.18; 'string,': 0.18; 'variable': 0.18; 'to:name :python-list@python.org': 0.20; 'fix': 0.21; 'do.': 0.22; 'noted': 0.22; 'trying': 0.22; 'am,': 0.23; 'passing': 0.23; 'this:': 0.23; 'tried': 0.24; '(most': 0.24; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'linux': 0.26; 'appreciated.': 0.27; 'error': 0.27; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'converting': 0.27; 'function': 0.28; 'looks': 0.29; 'accomplished': 0.29; 'code:': 0.29; "i'm": 0.30; 'code': 0.30; 'certain': 0.31; 'anyone': 0.32; 'included': 0.32; '[1]': 0.32; 'embedded': 0.32; 'run': 0.33; 'useful': 0.33; 'url:python': 0.33; 'call,': 0.33; 'displayed': 0.33; 'traceback': 0.33; 'utility': 0.33; 'file': 0.34; 'except': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'but': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'say': 0.37; 'received:209': 0.38; 'loss': 0.38; 'thank': 0.38; 'why': 0.39; 'data': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.40; 'called': 0.40; 'url:3': 0.60; 'your': 0.60; 'entire': 0.61; 'provide': 0.61; 'show': 0.62; 'here.': 0.62; 'is.': 0.63; 'more': 0.63; 'different': 0.63; 'complete': 0.63; 'mar': 0.65; 'python- list': 0.66; 'here': 0.66; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; '2.7.': 0.84; 'pain': 0.84; 'refuses': 0.84; 'reply-to:addr:python.org': 0.84; 'url:reference': 0.91; 'subject:With': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:from:date :message-id:subject:to:content-transfer-encoding; bh=T0MvYml1As1ykuDpNvmgVYmsy7P1N7li/yY7VqtghZU=; b=shgo6JLnGly2qyVHbq+pGQcrADbZbP4yly35g9UDubyBTVLaLNuBnGRCeIfR+NrEUA B/qwxeeBo009vWbksLrxDJlc1zLcvmaLH9oAliTOqfFvq192nS5hOfphHiiDS83KrS5Q oNlV9WtSsYErlh6FfRURTxf/sSsTUoQq4DcX5y9cEnrhXw8ZnxSU3rJlveLlfrllFUSq guhHk1hIwoMdAsd0SZ38wkbtfWiuioqIbualYeMm/0eJjN4SZ9bVORiXO0O8wMALd04H A3IZqa6LTktUkUqnnEd+JUM4lN5zMmXt6phgdOk++NO3WXoPCAiP6w6QVtF/zQJTHFKl LFxw== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:sender:in-reply-to :references:from:date:message-id:subject:to :content-transfer-encoding; bh=T0MvYml1As1ykuDpNvmgVYmsy7P1N7li/yY7VqtghZU=; b=m/TuYgANnRNm3YXdu8c0YBQ0WpJop1nfX35w+1U3hxd3xbvBHF+bx0yUyLb5zctHso E2HLW6kvpKIgC/QTefQWPs98jJxG4k2svAbq8odrYfAx6DKh8X2Wlj11baZC5F0j4fFy nBSee2Ed5KE+7F+BjJlkD+a09T3y7aj7H32y3brLeFm0BaD8YKn8dLJ77x6eniddAWCg RTcGLQ8Cw24ytXhTJ0z7Z0alQ6W9CtKjMc5YNKeh0nQb9qSinpkzOnZGdt9mHEzpuR0U kA9gQ09IlTQvoFPQ4D3odzaR8xNAWmaBjH6hbZ4Ty+kCuvXb4h+Ly2WI6JjXVqlZ31IQ GOyA== |
| X-Gm-Message-State | AD7BkJIfChdMJ+P/cjRqk5R0u9ywi6s6taSGw6WoLxusmOOYzh7BRJuGc9K1A696ETnHGW1O+jAtPe2UsEs1Cg== |
| X-Received | by 10.157.14.131 with SMTP id 3mr6398283otj.158.1458884072523; Thu, 24 Mar 2016 22:34:32 -0700 (PDT) |
| In-Reply-To | <Ju-dnWKBjbD8VWnLnZ2dnUU7-amdnZ2d@giganews.com> |
| X-Google-Sender-Auth | L2DAOp_AJfZNkzlKz7MrOqOG3s8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:105681 |
Show key headers only | View raw
On Fri, Mar 25, 2016 at 12:10 AM, Wildman via Python-list
<python-list@python.org> wrote:
> I have a program that I have been trying to rewrite so it will
> run on Python 2.7 and 3.4. It has been a pain to say the least.
> Thank $DIETY for aliases. Anyway, I got it all working except
> for one thing. The program has an embedded icon. It is displayed
> in the window's titlebar. The icon is a 16x16 png that has been
> base64 encoded using a Linux utility called memencoder. The code
> below works perfectly with Python 2.7. The icon data is complete
> for anyone that wants to try to run this code:
>
> encoded_icon = """\
[...]
> I tried converting the icon string to a byte variable like this:
>
> encoded_icon = bytes("""\
> iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAACBj
> (...)
> ZGlmeQAyMDE2LTAzLTIxVDE1OjE5OjI3LTA1OjAwe2m2vwAAAABJRU5ErkJggg==""")
>
>
> That give me a different error:
>
> Traceback (most recent call last):
> File "./myprogram.py", line 269, in <module>
> ZGlmeQAyMDE2LTAzLTIxVDE1OjE5OjI3LTA1OjAwe2m2vwAAAABJRU5ErkJggg==""")
> TypeError: string argument without an encoding
>
> I'm not sure what that means. I looks like it wants the string
> to be encoded but it already is.
The bytes constructor in Python 3 requires you to provide an encoding
(utf-8, ascii, latin-1, koi8, etc) when passing in a string, otherwise
it doesn't know what bytes you want and refuses to guess. You could
fix this by adding `encoding='ascii'` to the bytes() call–but I'm not
certain that that would work in 2.7, and there's a much easier method,
noted later.
> And why the reference to only
> the last line of the string?
Because the traceback would be huge if it included the entire function
call, and there's no need to. You can find the error from just that
line. It would be arguably more useful to show the first line, but
that's more difficult to do.
> I am at a loss here. Any help would be greatly appreciated.
What you need here is a bytes literal, which is accomplished by
prepending a 'b' to the string literal. Your `encoded_icon = """\`
just needs to become `encoded_icon = b"""\`. See here [1] for more
information.
--
Zach
[1] https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Problem With Embedded Icon and Python 3.4 Wildman <best_lay@yahoo.com> - 2016-03-25 00:10 -0500
Re: Problem With Embedded Icon and Python 3.4 Terry Reedy <tjreedy@udel.edu> - 2016-03-25 01:30 -0400
Re: Problem With Embedded Icon and Python 3.4 Wildman <best_lay@yahoo.com> - 2016-03-25 09:41 -0500
Re: Problem With Embedded Icon and Python 3.4 Zachary Ware <zachary.ware+pylist@gmail.com> - 2016-03-25 00:34 -0500
Re: Problem With Embedded Icon and Python 3.4 Wildman <best_lay@yahoo.com> - 2016-03-25 09:42 -0500
Re: Problem With Embedded Icon and Python 3.4 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-26 01:42 +0000
Re: Problem With Embedded Icon and Python 3.4 Wildman <best_lay@yahoo.com> - 2016-03-25 21:37 -0500
Re: Problem With Embedded Icon and Python 3.4 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-28 10:36 +0100
Re: Problem With Embedded Icon and Python 3.4 Wildman <best_lay@yahoo.com> - 2016-03-28 09:31 -0500
csiph-web