[issue3128] Regex causes python to hang up? / loop infinite?

2008-06-17 Thread André Fritzsche

New submission from André Fritzsche <[EMAIL PROTECTED]>:

After struggling around with my code for nearly 1 hour now, I found out
that one of my regular expressions with a special string causes python
to hang up - not really hang up, because the processor usage is at
nearly 100%, so I think the regex machine is looping infinite.

Here is the regex-string:

re_exc_line = re.compile (
# ignore everything before the first match
r'^.*' +
# first group (includes second | third)
r'(?:' +
 # second group "(line) (file)"
 r'(?:' +
  # (text to ignore, line [number])
  r'\([^,]+\s*,\s*line\s+(?P\d+)\)' +
  # any text ([filename]) any text
  r'.*\((?:(?P[^)]+))*\).*' +
 # end of second group
 r')' +
# or
r'|' +
 # third group "(file) (line)"
 r'(?:' +
  # ([filename])
  r'\((?:(?P[^)]+))*\)' +
  # any text (text to ignore, line [number]) any text
  r'.*\([^,]+\s*,\s*line\s+(?P\d+)\).*' +
  # end of third group
 r')' +
# end of first group
r')' +
# any text after it
r'.*$'
, re.I
)

It should match either the construct:

1. """some optional text (text to ignore, line [12]) ([any_filename])
followed by optional text"""

or:

2. """some optional text ([any_filename]) (text to ignore, line [12])
followed by optional text"""

If first text matches, it is put into 'line1' and 'file1' and if the
second one matches into 'line2' and 'file2' of the groupdict.

For the upper both examples everything is ok, but having the following
string (I had to change some pathnames, because they contained customer
names):
msg = (
r"Error: Error during parsing: invalid syntax " +
r"(D:\Projects\retest\ver_700\lib\_test\test_sapekl.py, line 14) " +
r"-- Error during parsing: invalid syntax " + 
r"(D:\projects\retest\ver_700\modules\sapekl\__init__.py, line 21) " +
r"-- Attempted relative import in non-package, or beyond toplevel " +
r"package")

used with the upper regex:

re_exc_line.match(msg)

is running for two hours now (on a 3Ghz Machine)!

I've attached everything as an example file and hope, I could help you.

--
components: Regular Expressions
files: re_problem.py
messages: 68304
nosy: computercrustie
severity: normal
status: open
title: Regex causes python to hang up? / loop infinite?
type: behavior
versions: Python 2.5
Added file: http://bugs.python.org/file10642/re_problem.py

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3128>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3128] Regex causes python to hang up? / loop infinite?

2008-06-17 Thread André Fritzsche

André Fritzsche <[EMAIL PROTECTED]> added the comment:

Thank you for this answer.
It solves my problem, but I think that the issues ist still existing -
or not? (The regex is running on - 3 hours now)

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3128>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3128] Regex causes python to hang up? / loop infinite?

2008-06-17 Thread André Fritzsche

André Fritzsche <[EMAIL PROTECTED]> added the comment:

Further I was, because the upper listed string wasn't expected for this
code (until it occured the first time ;-) )

Normally there has been only one occurence of "(file) (.., line)" or
"(.., line) (file)" per string, so the regex did quite do what I
expected - never the less you are right - instead of the '*' operator I
should have used a '?' operator for the repetition.

So far many thanks for your recommendations - but the question is if it
is ok that a regex may block a process such a long time?

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3128>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3128] Regex causes python to hang up? / loop infinite?

2008-06-17 Thread André Fritzsche

André Fritzsche <[EMAIL PROTECTED]> added the comment:

Thanks for the link, it was very interesting to read what can happen in
some circumstances.

I think, the first two chapters can match to the problem.

So the type of this issue should be feature request ;-)

Never the less I learned something new, so the invested time wasn't wasted.

Greez

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3128>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2047] shutil.destinsrc returns wrong result when source path matches beginning of destination path

2008-02-07 Thread André Fritzsche

New submission from André Fritzsche:

shutil.destinsrc(src,dst)

Checks if 'dst' starts with 'src', which can return a wrong result if
'dst' even starts with 'scr' but isn't really a subdirector of it. E.g.
(src=r'C:\data', dst=r'C:\data.old') returned true, although dst isn't a
subdirectory of src.

I tried to fix this creating the absolute paths of 'dst' and 'src'
appended the path seperator, if there wasn't one. Then did the check
again and now the result is correct.

See the diff file I've appended (and hopefully created correctly)

--
components: Library (Lib)
files: shutil.diff
messages: 62193
nosy: computercrustie
severity: normal
status: open
title: shutil.destinsrc returns wrong result when source path matches beginning 
of destination path
type: behavior
versions: Python 2.4
Added file: http://bugs.python.org/file9389/shutil.diff

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2047>
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2047] shutil.destinsrc returns wrong result when source path matches beginning of destination path

2008-02-10 Thread André Fritzsche

André Fritzsche added the comment:

Raghuram, you've been too fast ;-)

Your test matches the problem. I don't know if it happens on Linux, but
on my Win32 Installation the test 'test_destinsrc_2' fails with an 
AssertionError 'destinsrc() wrongly concluded that dst
(@test\srcdir.new) is in src (@test\srcdir)'.

Using the submitted patch everything comes out with 'Ok'.

I've appended the failing test output.

Added file: http://bugs.python.org/file9404/test_shutil_orig.txt

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2047>
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com