Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #71076 > unrolled thread

Re: data: protocol

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2014-05-07 22:17 -0600
Last post2014-05-07 22:17 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: data: protocol Ian Kelly <ian.g.kelly@gmail.com> - 2014-05-07 22:17 -0600

#71076 — Re: data: protocol

FromIan Kelly <ian.g.kelly@gmail.com>
Date2014-05-07 22:17 -0600
SubjectRe: data: protocol
Message-ID<mailman.9760.1399522689.18130.python-list@python.org>
On Wed, May 7, 2014 at 4:42 AM, Robin Becker <robin@reportlab.com> wrote:
> I have an outstanding request for ReportLab to allow images to be opened
> using the data: scheme. That used to be supported in python 2.7 using
> urllib, but in python 3.3 urllib2 --> urllib and at least the default
> urlopener doesn't support data:
>
> Is there a way to use the residual legacy of the old urllib code that's now
> in urllib.URLopener to open unusual schemes? I know it can be used directly
> eg
>
> urllib.request.URLopener().open('data:.........')
>
> but that seems to leave the splitting & testing logic up to me when it
> logically belongs in some central place ie urllib.request.urlopen.

Seems to be fixed in Python 3.4:

Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:24:06) [MSC v.1600 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib.request
>>> url = 'data:text/plain;charset=UTF-8,Hello%20World'
>>> urllib.request.urlopen(url).read()
b'Hello World'

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web