[issue24108] fnmatch.translate('*.txt') fails

2015-05-01 Thread Christophe BAL

New submission from Christophe BAL:

Hello.

I find the following bug on Python 3.4.

>>> import fnmatch, re
>>> regex = fnmatch.translate('*.txt')
>>> regex
'.*\\.txt\\Z(?ms)'

The string regex should be '.*\\.txt$'.

--
components: asyncio
messages: 242346
nosy: gvanrossum, haypo, projetmbc, yselivanov
priority: normal
severity: normal
status: open
title: fnmatch.translate('*.txt') fails
versions: Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24108] fnmatch.translate('*.txt') fails

2015-05-01 Thread Merlijn van Deen

Merlijn van Deen added the comment:

As far as I can see, the regex is correct:

\Z
Matches only at the end of the string.

(?iLmsux)
The group matches the empty string; the letters set the corresponding flags: 
(...)
  - re.M (multi-line),
  - re.S (dot matches all)

See https://docs.python.org/3.4/library/re.html

Do you have an example where the regex does not match a file it should match 
(or matches a file it shouldn't)?

--
nosy: +valhallasw

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24108] fnmatch.translate('*.txt') fails

2015-05-01 Thread Christophe BAL

Christophe BAL added the comment:

Ok.

But in that case, the official documentation should be updated because it
saids that string regex is  *'.*\\.txt\\Z(?ms)'*  and not  *'.*\\.txt$'*.

On the other hand, using this writing seems a bit strange. The 2nd one
should do the job.

*Christophe BAL*
*Enseignant de mathématiques en Lycée **et développeur Python amateur*
*---*
*French math teacher in a "Lycée" **and **Python **amateur developer*

2015-05-01 21:42 GMT+02:00 Merlijn van Deen :

>
> Merlijn van Deen added the comment:
>
> As far as I can see, the regex is correct:
>
> \Z
> Matches only at the end of the string.
>
> (?iLmsux)
> The group matches the empty string; the letters set the corresponding
> flags: (...)
>   - re.M (multi-line),
>   - re.S (dot matches all)
>
> See https://docs.python.org/3.4/library/re.html
>
> Do you have an example where the regex does not match a file it should
> match (or matches a file it shouldn't)?
>
> --
> nosy: +valhallasw
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24108] fnmatch.translate('*.txt') fails

2015-05-01 Thread Yury Selivanov

Changes by Yury Selivanov :


--
nosy:  -yselivanov

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24108] fnmatch.translate('*.txt') fails

2015-05-01 Thread Merlijn van Deen

Merlijn van Deen added the comment:

They are subtly different; the new regex also matches filenames with newlines, 
the old one doesn't (see Issue #6665 [1]).

Patch (although crazily minor) attached. With some fuzz, it applies on 
everything from 2.6..default.

[1] https://bugs.python.org/issue6665

--
assignee:  -> docs@python
components: +Documentation -asyncio
keywords: +patch
nosy: +docs@python
Added file: http://bugs.python.org/file39261/default.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24108] fnmatch.translate('*.txt') fails

2015-05-01 Thread Christophe BAL

Christophe BAL added the comment:

You're totally wrong and I am wrong.

There is still the tiny problem of the documentation.

Thanks for all.

*Christophe BAL*
*Enseignant de mathématiques en Lycée **et développeur Python amateur*
*---*
*French math teacher in a "Lycée" **and **Python **amateur developer*

2015-05-01 22:16 GMT+02:00 Merlijn van Deen :

>
> Merlijn van Deen added the comment:
>
> They are subtly different; the new regex also matches filenames with
> newlines, the old one doesn't (see Issue #6665 [1]).
>
> Patch (although crazily minor) attached. With some fuzz, it applies on
> everything from 2.6..default.
>
> [1] https://bugs.python.org/issue6665
>
> --
> assignee:  -> docs@python
> components: +Documentation -asyncio
> keywords: +patch
> nosy: +docs@python
> Added file: http://bugs.python.org/file39261/default.diff
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24108] fnmatch.translate('*.txt') fails

2015-05-01 Thread Christophe BAL

Christophe BAL added the comment:

Oups, sorry I want to say that you are totally RIGHT, and I am definitely
WRONG. :-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24108] fnmatch.translate('*.txt') fails

2015-05-01 Thread Guido van Rossum

Changes by Guido van Rossum :


--
nosy:  -gvanrossum

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24108] fnmatch.translate('*.txt') fails

2015-05-02 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c5c65ef84a77 by R David Murray in branch '3.4':
#24108: Update fnmatch.translate example to show correct output.
https://hg.python.org/cpython/rev/c5c65ef84a77

New changeset cc6aed8ecb0d by R David Murray in branch 'default':
Merge: #24108: Update fnmatch.translate example to show correct output.
https://hg.python.org/cpython/rev/cc6aed8ecb0d

New changeset 5d356223f075 by R David Murray in branch '2.7':
#24108: Update fnmatch.translate example to show correct output.
https://hg.python.org/cpython/rev/5d356223f075

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24108] fnmatch.translate('*.txt') fails

2015-05-02 Thread R. David Murray

R. David Murray added the comment:

Thanks Christophe and Merlijn.

--
nosy: +r.david.murray
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
versions: +Python 2.7, Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com