Re: [Python-Dev] Pathlib enhancments - method name only

2016-04-09 Thread Greg Ewing
On 9 April 2016 at 23:02, R. David Murray wrote: That is, a 'filename' is the identifier we've assigned to this thing pointed to by an inode in linux, but an os path is a text representation of the path from the root filename to a specified filename. That is, the path *is* the name, so to say

Re: [Python-Dev] Pathlib enhancments - method name only

2016-04-09 Thread Nick Coghlan
On 10 April 2016 at 15:58, Greg Ewing wrote: > Brett Cannon wrote: > >> Depends if you use `/` or `\` as your path separator > > > Or whether your pathnames look entirely different, e.g VMS: > > device:[topdir.subdir.subsubdir]filename.ext;version > > Pathnames are very much OS-dependent in both

Re: [Python-Dev] Pathlib enhancments - method name only

2016-04-09 Thread Greg Ewing
Eric Snow wrote: All this matters because it impacts the value returned from __ospath__(). Should it return the string representation of the path for the current OS or some standardized representation? What standardized representation? I'm not aware of such a thing. I'd expect the former. H

Re: [Python-Dev] pathlib (was: Defining a path protocol)

2016-04-09 Thread Greg Ewing
Nick Coghlan wrote: We want to be able to readily use the protocol helper in builtin modules like os and low level Python modules like os.path, which means we want it to be much lower down in the import hierarchy than pathlib. Also, it's more general than that. It works on any object that wants

Re: [Python-Dev] Pathlib enhancments - method name only

2016-04-09 Thread Greg Ewing
Brett Cannon wrote: Depends if you use `/` or `\` as your path separator Or whether your pathnames look entirely different, e.g VMS: device:[topdir.subdir.subsubdir]filename.ext;version Pathnames are very much OS-dependent in both syntax *and* semantics. Even the main two in use today (un

Re: [Python-Dev] Pathlib enhancements - acceptable inputs and outputs for __fspath__ and os.fspath()

2016-04-09 Thread Nick Coghlan
On 10 April 2016 at 02:41, Ethan Furman wrote: > If we add os.fspath(), but don't allow bytes to be returned from it, our > above example looks more like: > > if isinstance(a_path_thingy, bytes): > # because os can accept bytes > pass > else: > a_path_thingy = os.fspath(a_pat

Re: [Python-Dev] PEP 506 secrets module

2016-04-09 Thread Steven D'Aprano
I've just spotted this email from Guido, sorry about the delay in responding. Further comments below. On Thu, Jan 14, 2016 at 10:47:09AM -0800, Guido van Rossum wrote: > I think the discussion petered out and nobody asked me to approve it yet > (or I lost track of it). I'm almost happy to appr

Re: [Python-Dev] Pathlib enhancments - method name only

2016-04-09 Thread Nick Coghlan
On 9 April 2016 at 23:02, R. David Murray wrote: > That is, a 'filename' is the identifier we've assigned to this thing > pointed to by an inode in linux, but an os path is a text representation > of the path from the root filename to a specified filename. That is, > the path *is* the name, so to

Re: [Python-Dev] Challenge: Please break this! (a.k.a restricted mode revisited)

2016-04-09 Thread Nick Coghlan
On 9 April 2016 at 22:43, Victor Stinner wrote: > Please don't loose time trying yet another sandbox inside CPython. It's just > a waste of time. It's broken by design. > > Please read my email about my attempt (pysandbox): > https://lwn.net/Articles/574323/ > > And the LWN article: > https://lwn.

Re: [Python-Dev] Incomplete Internationalization in Argparse Module

2016-04-09 Thread Grady Martin
Excellent. Issue/patch here: http://bugs.python.org/issue26726 On 2016年04月09日 08時16分, Guido van Rossum wrote: OK, so this should be taken to the bug tracker. On Saturday, April 9, 2016, Grady Martin wrote: I agree. However, an incorrect choice for an argument with a choices parameter res

[Python-Dev] Pathlib enhancements - acceptable inputs and outputs for __fspath__ and os.fspath()

2016-04-09 Thread Ethan Furman
On 04/09/2016 12:48 AM, Nick Coghlan wrote: > Considering the helper function usage, here's some examples in > combination with os.fsencode and os.fsdecode: > > # Status quo for binary/text path conversions > text_path = os.fsdecode(bytes_path) > bytes_path = os.fsencode(text_path) > > #

Re: [Python-Dev] Defining a path protocol

2016-04-09 Thread Ethan Furman
On 04/09/2016 07:32 AM, Nikolaus Rath wrote: On Apr 07 2016, Donald Stufft wrote: On Apr 7, 2016, at 6:48 AM, Nikolaus Rath wrote: Does anyone anticipate any classes other than those from pathlib to come with such a method? It seems like it would be reasonable for pathlib.Path to call fspa

Re: [Python-Dev] Defining a path protocol (was: When should pathlib stop being provisional?)

2016-04-09 Thread Ethan Furman
On 04/09/2016 03:51 AM, Koos Zevenhoven wrote: On Sat, Apr 9, 2016 at 10:16 AM, Ethan Furman wrote: 3.5.0 scandir supports bytes: Maybe it's the bytes support in scandir that should be deprecated? (And not bytes support in general, which cannot be done on posix, as I hear Stephen T. will te

Re: [Python-Dev] Incomplete Internationalization in Argparse Module

2016-04-09 Thread Guido van Rossum
OK, so this should be taken to the bug tracker. On Saturday, April 9, 2016, Grady Martin wrote: > I agree. However, an incorrect choice for an argument with a choices > parameter results in this string. > > On 2016年04月08日 18時12分, Guido van Rossum wrote: > >> >> That string looks like it is aime

Re: [Python-Dev] Defining a path protocol

2016-04-09 Thread Nikolaus Rath
On Apr 07 2016, Donald Stufft wrote: >> On Apr 7, 2016, at 6:48 AM, Nikolaus Rath wrote: >> >> Does anyone anticipate any classes other than those from pathlib to come >> with such a method? > > > It seems like it would be reasonable for pathlib.Path to call fspath on the > path passed to pathli

Re: [Python-Dev] Pathlib enhancments - method name only

2016-04-09 Thread R. David Murray
On Sat, 09 Apr 2016 17:48:38 +1000, Nick Coghlan wrote: > On 9 April 2016 at 04:25, Brett Cannon wrote: > > On Fri, 8 Apr 2016 at 11:13 Ethan Furman wrote: > >> On 04/08/2016 10:46 AM, Koos Zevenhoven wrote: > >> > On Fri, Apr 8, 2016 at 7:42 PM, Chris Barker wrote: > >> >> On Fri, Apr 8, 201

Re: [Python-Dev] Challenge: Please break this! (a.k.a restricted mode revisited)

2016-04-09 Thread Maciej Fijalkowski
I'm with Victor here. In fact I tried (and failed) to convince Victor that the approach is entirely unworkable when he was starting, don't be the next one :-) On Sat, Apr 9, 2016 at 3:43 PM, Victor Stinner wrote: > Please don't loose time trying yet another sandbox inside CPython. It's just > a w

Re: [Python-Dev] Challenge: Please break this! (a.k.a restricted mode revisited)

2016-04-09 Thread Victor Stinner
Please don't loose time trying yet another sandbox inside CPython. It's just a waste of time. It's broken by design. Please read my email about my attempt (pysandbox): https://lwn.net/Articles/574323/ And the LWN article: https://lwn.net/Articles/574215/ There are a lot of safe ways to run CPyth

Re: [Python-Dev] Defining a path protocol (was: When should pathlib stop being provisional?)

2016-04-09 Thread Koos Zevenhoven
On Sat, Apr 9, 2016 at 10:16 AM, Ethan Furman wrote: > On 04/09/2016 12:07 AM, Victor Stinner wrote: >> >> os.DirEntry doesn't support bytes: os.scandir() only accept str. It's a >> deliberate choice. > > > 3.5.0 scandir supports bytes: > > --> huh = list(scandir(b'.')) > --> huh > [, , b'__MACOS

Re: [Python-Dev] Pathlib enhancments - method name only

2016-04-09 Thread Giampaolo Rodola'
On Fri, Apr 8, 2016 at 9:09 PM, Chris Angelico wrote: > On Sat, Apr 9, 2016 at 5:03 AM, Chris Barker > wrote: > > On Fri, Apr 8, 2016 at 11:34 AM, Koos Zevenhoven > wrote: > >> > >> > > >> > __pathstr__ # pathstring > >> > > >> > >> Or perhaps __pathstring__ in case it may be or return byte str

Re: [Python-Dev] Question about the current implementation of str

2016-04-09 Thread Victor Stinner
2016-04-09 9:52 GMT+02:00 Victor Stinner : > But the hash is used as an heuristic to decide if a string is "immutable" or > not, the refcount is also used by the heuristic. If the string is immutable, > an operation like resize must create a new string. I'm talking about this private function: st

Re: [Python-Dev] Question about the current implementation of str

2016-04-09 Thread Serhiy Storchaka
On 09.04.16 10:52, Victor Stinner wrote: Le 9 avr. 2016 03:04, "Larry Hastings" mailto:la...@hastings.org>> a écrit : > Although the str object is immutable from Python's perspective, the C object itself is mutable. For example, for dynamically-created strings the hash field may be lazy-compute

Re: [Python-Dev] Incomplete Internationalization in Argparse Module

2016-04-09 Thread Grady Martin
I agree. However, an incorrect choice for an argument with a choices parameter results in this string. On 2016年04月08日 18時12分, Guido van Rossum wrote: That string looks like it is aimed at the developer, not the user of the program, so it makes sense not to translate it. On Fri, Apr 8, 2016 a

Re: [Python-Dev] Question about the current implementation of str

2016-04-09 Thread Victor Stinner
Le 9 avr. 2016 03:04, "Larry Hastings" a écrit : > Although the str object is immutable from Python's perspective, the C object itself is mutable. For example, for dynamically-created strings the hash field may be lazy-computed and cached inside the object. Yes, the hash is computed once on dema

Re: [Python-Dev] Pathlib enhancments - method name only

2016-04-09 Thread Nick Coghlan
On 9 April 2016 at 04:25, Brett Cannon wrote: > On Fri, 8 Apr 2016 at 11:13 Ethan Furman wrote: >> On 04/08/2016 10:46 AM, Koos Zevenhoven wrote: >> > On Fri, Apr 8, 2016 at 7:42 PM, Chris Barker wrote: >> >> On Fri, Apr 8, 2016 at 9:02 AM, Koos Zevenhoven wrote: >> >> >>> I'm still thinking

Re: [Python-Dev] Question about the current implementation of str

2016-04-09 Thread Nick Coghlan
On 9 April 2016 at 10:56, Larry Hastings wrote: > > > I have a straightforward question about the str object, specifically the > PyUnicodeObject. I've tried reading the source to answer the question > myself but it's nearly impenetrable. So I was hoping someone here who > understands the current

Re: [Python-Dev] Defining a path protocol (was: When should pathlib stop being provisional?)

2016-04-09 Thread Ethan Furman
On 04/09/2016 12:07 AM, Victor Stinner wrote: os.DirEntry doesn't support bytes: os.scandir() only accept str. It's a deliberate choice. 3.5.0 scandir supports bytes: --> huh = list(scandir(b'.')) --> huh [, , b'__MACOSX'>, , , b'index.html'>] --> huh[0].path b'./minicourse-ajax-project' --

Re: [Python-Dev] Defining a path protocol (was: When should pathlib stop being provisional?)

2016-04-09 Thread Victor Stinner
os.DirEntry doesn't support bytes: os.scandir() only accept str. It's a deliberate choice. I strongly suggest to only support Unicode for filenames in Python 3. So __fspath__ must only return str, or a TypeError must be raised. Victor ___ Python-Dev mai

Re: [Python-Dev] Defining a path protocol (was: When should pathlib stop being provisional?)

2016-04-09 Thread Nick Coghlan
On 9 April 2016 at 02:02, Koos Zevenhoven wrote: > I'm still thinking a little bit about 'pathname', which to me sounds > more like a string than fspath does [1]. It would be nice to have the > string/path distinction especially when pathlib adoption grows larger. > But who knows, maybe somewhere