Re: [Python-Dev] PEP-8 wart... it recommends short names because of DOS

2015-10-21 Thread eryksun
On 10/21/15, Serhiy Storchaka  wrote:
> On 21.10.15 04:25, Gregory P. Smith wrote:
>> https://www.python.org/dev/peps/pep-0008/#names-to-avoid
>>
>> /"Since module names are mapped to file names, and some file systems are
>> case insensitive and truncate long names, it is important that module
>> names be chosen to be fairly short -- this won't be a problem on Unix,
>> but it may be a problem when the code is transported to older Mac or
>> Windows versions, or DOS."/
>>
>> There haven't been computers with less than 80 character file or path
>> name element length limits in wide use in decades... ;)
>
> We should also avoid special file names like con.py or lpt1.py.

Other file names to avoid on Windows are conin$.py, conout$.py,
aux.py, prn.py, nul.py, lpt[1-9].py, and com[1-9].py.

Using these device names in a file name requires the fully qualified
wide-character path, prefixed by \\?\. Incidentally this prefix also
allows paths that have up to 32768 characters, if there's concern that
long module names in packages might exceed the Windows 260-character
limit.

Here's an example of what would actually be opened for con.py, etc, at
least on my current Windows 10 machine:

devs = ('aux prn com1 com9 lpt1 lpt9 '
'nul con conin$ conout$'.split())

for dev in devs:
ntpath = to_nt(r'C:\%s.py' % dev)
print(ntpath.ljust(11), '=>' ,query_link(ntpath))

output:

\??\aux => \DosDevices\COM1
\??\prn => \DosDevices\LPT1
\??\com1=> object name not found
\??\com9=> object name not found
\??\lpt1=> \Device\Parallel0
\??\lpt9=> object name not found
\??\nul => \Device\Null
\??\con => \Device\ConDrv\Console
\??\conin$  => \Device\ConDrv\CurrentIn
\??\conout$ => \Device\ConDrv\CurrentOut

The \\?\ prefix avoids DOS name translation. The only change made by
the system is to replace \\?\ with \?? in the path:

for dev in devs:
print(to_nt(r'\\?\C:\%s.py' % dev))

output:

\??\C:\aux.py
\??\C:\prn.py
\??\C:\com1.py
\??\C:\com9.py
\??\C:\lpt1.py
\??\C:\lpt9.py
\??\C:\nul.py
\??\C:\con.py
\??\C:\conin$.py
\??\C:\conout$.py

On this machine, \??\C: is a link to \Device\HarddiskVolume2.

(to_nt and query_link call the native API functions
RtlDosPathNameToNtPathName_U, NtOpenSymbolicLinkObject, and
NtQuerySymbolicLinkObject. Note that Microsoft doesn't support calling
the native NT API from applications in user mode.)
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] PEP-8 wart... it recommends short names because of DOS

2015-10-21 Thread Serhiy Storchaka

On 21.10.15 04:25, Gregory P. Smith wrote:

https://www.python.org/dev/peps/pep-0008/#names-to-avoid

/"Since module names are mapped to file names, and some file systems are
case insensitive and truncate long names, it is important that module
names be chosen to be fairly short -- this won't be a problem on Unix,
but it may be a problem when the code is transported to older Mac or
Windows versions, or DOS."/

There haven't been computers with less than 80 character file or path
name element length limits in wide use in decades... ;)


We should also avoid special file names like con.py or lpt1.py.


___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] PEP-8 wart... it recommends short names because of DOS

2015-10-20 Thread Gregory P. Smith
https://www.python.org/dev/peps/pep-0008/#names-to-avoid

*"Since module names are mapped to file names, and some file systems are
case insensitive and truncate long names, it is important that module names
be chosen to be fairly short -- this won't be a problem on Unix, but it may
be a problem when the code is transported to older Mac or Windows versions,
or DOS."*

There haven't been computers with less than 80 character file or path name
element length limits in wide use in decades... ;)

-gps
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] PEP-8 wart... it recommends short names because of DOS

2015-10-20 Thread David Mertz
DOS Python programmers probably can't use `concurrent` or
`multiprocessing`. ☺
On Oct 20, 2015 6:26 PM, "Gregory P. Smith"  wrote:

> https://www.python.org/dev/peps/pep-0008/#names-to-avoid
>
> *"Since module names are mapped to file names, and some file systems are
> case insensitive and truncate long names, it is important that module names
> be chosen to be fairly short -- this won't be a problem on Unix, but it may
> be a problem when the code is transported to older Mac or Windows versions,
> or DOS."*
>
> There haven't been computers with less than 80 character file or path name
> element length limits in wide use in decades... ;)
>
> -gps
>
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/mertz%40gnosis.cx
>
>
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com