[reportlab-users] open_for_read and Window file paths

John J. Lee reportlab-users@reportlab.com
Thu, 3 Jun 2004 09:44:14 +0100 (GMT Daylight Time)


On Thu, 3 Jun 2004, Jerome Alet wrote:
[...]
> in urlparse.py file you'll see some global variables which contain
> the lists of allowed schemes
>
> just validate against these lists, not by using the urlparse method

I haven't checked, but I assume those are just to cover the cases that
don't completely fit the generic syntax (RFC 2396?).  But there do seem to
be quite a few listed, so maybe not...

Anyway, checking against a fixed list would be annoying -- there's always
another scheme you've never heard of (svn+ssh, ...).

How about this:

diff -r1.80 utils.py
450c450
<         if not P[0] or P[0]=='file': raise ValueError
---
>         if not P[0] or P[0]=='file' or len(P[0]) == 1: raise ValueError
453c453
<         return open_for_read_by_name(P[2],mode)
---
>         return open_for_read_by_name(name,mode)


I don't understand why that P[2] is there, BTW: if it's not a URL,
shouldn't it just be using the original name argument, as patched above?


John