Re: [Python-Dev] os.path.normcase rationale?

2010-10-03 Thread Dan Villiom Podlaski Christiansen

On 3 Oct 2010, at 02:35, Nir Soffer wrote:


On Sat, Sep 25, 2010 at 1:36 AM, James Y Knight  wrote:


An OSX code sketch is available here (summary: call FSPathMakeRef  
to get an
FSRef from a path string, then FSRefMakePath to make it back into a  
path,
which will then have the correct case). And note that it only works  
if the

file actually exists.


http://stackoverflow.com/questions/370186/how-do-i-find-the-correct-case-of-a-filename

It would indeed be useful to have that be available in Python.



There is a much simpler way:


from Carbon import File
File.FSRef('/tmp/foo').as_pathname()

'/private/tmp/Foo'

Note that this is much slower compared to os.path.exists.


This won't work in py3k; the Carbon modules were removed in 3.0. A  
simpler alternative would probably be the F_GETPATH fcntl. An example:


Python 3.1.2 (r312:79147, Jul 11 2010, 18:21:56)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from fcntl import fcntl
>>> from os.path import basename, exists
>>> from os import remove
>>>
>>> F_GETPATH = 50
>>>
>>> if exists('/tmp/å'):
...   remove('/tmp/å')
...
>>> open('/tmp/å', 'w').close()
>>> f = open(b'/tmp/A\xcc\x8a')
>>>
>>> a = f.name
>>> b = fcntl(f, F_GETPATH, b'\0' * 1024).rstrip(b'\0')
>>>
>>> a, b
(b'/tmp/A\xcc\x8a', b'/private/tmp/\xc3\xa5')
>>> a.decode('utf-8'), b.decode('utf-8')
('/tmp/Å', '/private/tmp/å')

--

Dan Villiom Podlaski Christiansen
[email protected]



smime.p7s
Description: S/MIME cryptographic signature
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] os.path.normcase rationale?

2010-10-03 Thread James Y Knight
On Oct 3, 2010, at 9:18 AM, Dan Villiom Podlaski Christiansen wrote:
> A simpler alternative would probably be the F_GETPATH fcntl. An example:

That requires that you have permission to open the file (and to actually do so 
which might have other effects), while the File Manager's FSRef method does not.

If Python adds a cross-platform function to do this canonicalization, users 
don't have to worry about how easy it is to invoke in pure-python...

James
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] framework build for 2.7 using old sqlite?

2010-10-03 Thread Doug Hellmann
I'm trying to write a little program that uses the full text search extension 
module for sqlite with Python 2.7 on Snow Leopard.  I installed Python by 
downloading the DMG file from python.org.  According to the Python docs 
(http://docs.python.org/library/sqlite3.html#sqlite3.Connection.enable_load_extension),
 2.7 should include the functions for handling extension modules, but when I 
try to use them they are not defined (I get an AttributeError when I call the 
related methods on the Connection object).

In Modules/_sqlite/connection.c I see that there is an #ifdef for 
HAVE_LOAD_EXTENSION, which is in turn only defined if both the version number 
is high enough and SQLITE_OMIT_LOAD_EXTENSION is not set.

I think the problem is that the build of Python in the DMG I download was 
created with an old version of the SQLite libraries:

farnsworth:dhellmann:~:503 $ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python

farnsworth:dhellmann:~:501 $ python
Python 2.7 (r27:82508, Jul  3 2010, 21:12:11) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.version_info
(2, 6, 0)


Can anyone confirm that the installer image for OS X 10.5 and later 
(http://python.org/ftp/python/2.7/python-2.7-macosx10.5.dmg) was created with 
an old SQLite library?  Is there some way to update that DMG, or do I need to 
build Python from source myself?

Thanks,
Doug

___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] framework build for 2.7 using old sqlite?

2010-10-03 Thread Doug Hellmann

On Oct 3, 2010, at 11:29 AM, Doug Hellmann wrote:

> I'm trying to write a little program that uses the full text search extension 
> module for sqlite with Python 2.7 on Snow Leopard.  I installed Python by 
> downloading the DMG file from python.org.  According to the Python docs 
> (http://docs.python.org/library/sqlite3.html#sqlite3.Connection.enable_load_extension),
>  2.7 should include the functions for handling extension modules, but when I 
> try to use them they are not defined (I get an AttributeError when I call the 
> related methods on the Connection object).
> 
> In Modules/_sqlite/connection.c I see that there is an #ifdef for 
> HAVE_LOAD_EXTENSION, which is in turn only defined if both the version number 
> is high enough and SQLITE_OMIT_LOAD_EXTENSION is not set.
> 
> I think the problem is that the build of Python in the DMG I download was 
> created with an old version of the SQLite libraries:
> 
>   farnsworth:dhellmann:~:503 $ which python
>   /Library/Frameworks/Python.framework/Versions/2.7/bin/python
> 
>   farnsworth:dhellmann:~:501 $ python
>   Python 2.7 (r27:82508, Jul  3 2010, 21:12:11) 
>   [GCC 4.0.1 (Apple Inc. build 5493)] on darwin
>   Type "help", "copyright", "credits" or "license" for more information.
>   >>> import sqlite3
>   >>> sqlite3.version_info
>   (2, 6, 0)

Forget that, the version info is for pysqlite, not the underlying libraries.

I found that Python's setup.py has SQLITE_OMIT_LOAD_EXTENSION set, which 
disables this feature (http://svn.python.org/view?view=rev&revision=78688).

Doug

___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] r85152 - tracker/instances/python-dev/config.ini.template

2010-10-03 Thread Martin v. Löwis

Modified: tracker/instances/python-dev/config.ini.template
+[django]
+# generate on a per-instance basis
+secret_key = 'e...@4s$*(idwm5-87teftxlksckmy8$tyo7(tm!n-5x)zeuheex'


I assume the secrecy of this is rather irrelevant?


It's only the template. In the instance, you have to replace it with
some value, if you care about the secrecy (which I did).

Regards,
Martin

___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Rietveld integration into Roundup

2010-10-03 Thread Daniel Stutzbach
On Sat, Oct 2, 2010 at 3:55 PM, "Martin v. Löwis" wrote:

> I'll have to come up with a better way to determine the branch
> which a patch was created on.
>

That would also be helpful for those of us using DVCS software to talk to
the svn server. :-)

-- 
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC 
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Rietveld integration into Roundup

2010-10-03 Thread Senthil Kumaran
Thanks Martin, this is really good.

On Sun, Oct 3, 2010 at 1:33 AM, "Martin v. Löwis"  wrote:
>  Patches are skipped if:
>  * they have been added to Rietveld already
>  * they have no clear base version (i.e. they don't originate
>    from svn diff)
>  * they belong to no or a closed issue
>  * they apply to a patch that is not currently supported
>    (only trunk, 2.6, 2.7, 3.1, py3k are currently supported)

One comment:

I feel that, only if a roundup issue has patch, the corresponding
rietveld issue be created, it is more helpful there and avoids
needless duplication.


-- 
Senthil
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Inclusive Range

2010-10-03 Thread Eviatar Bach
Hello,

I have a proposal of making the range() function inclusive; that is,
range(3) would generate 0, 1, 2, and 3, as opposed to 0, 1, and 2. Not only
is it more intuitive, it also seems to be used often, with coders often
writing range(0, example+1) to get the intended result. It would be easy to
implement, and though significant, is not any more drastic than changing
print to a function in Python 3. Of course, if this were done, slicing
behaviour would have to be adjusted accordingly.

What are your thoughts?
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Inclusive Range

2010-10-03 Thread Benjamin Peterson
2010/10/3 Eviatar Bach :
> Hello,
>
> I have a proposal

See the python-ideas mailing list.

> of making the range() function inclusive; that is,
> range(3) would generate 0, 1, 2, and 3, as opposed to 0, 1, and 2. Not only
> is it more intuitive, it also seems to be used often, with coders often
> writing range(0, example+1) to get the intended result. It would be easy to
> implement, and though significant, is not any more drastic than changing
> print to a function in Python 3..

Yes, it is. It's much more subtle.

>
> What are your thoughts?

Completely backwards incompatible. -1


-- 
Regards,
Benjamin
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Inclusive Range

2010-10-03 Thread Cameron Simpson
On 03Oct2010 20:04, Eviatar Bach  wrote:
| I have a proposal of making the range() function inclusive; that is,
| range(3) would generate 0, 1, 2, and 3, as opposed to 0, 1, and 2. Not only
| is it more intuitive, it also seems to be used often, with coders often
| writing range(0, example+1) to get the intended result. It would be easy to
| implement, and though significant, is not any more drastic than changing
| print to a function in Python 3. Of course, if this were done, slicing
| behaviour would have to be adjusted accordingly.

1: take this to python-ieas please instead of python-dev.
2: -1; the current behaviour is, IMHO, highly desirable.
   Example:
 x=3; y=7; z=12
 s='ahahahahahahahaha'
 assert s[:x]+s[x:y]+s[y:z]+s[z:] == s
   No icky +1 hacks in there.
3: I find myself doing the +1 thing very _un_often, myself.

Cheers,
-- 
Cameron Simpson  DoD#743
http://www.cskk.ezoshosting.com/cs/

The hardest years in life are those between ten and seventy.
- Helen Hayes (at age 84)
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com