[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-11-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I fully agree with Éric.  Just don't do this.

--
nosy: +serhiy.storchaka
resolution:  - invalid
status: open - pending

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-11-13 Thread Stefan Krah

Stefan Krah added the comment:

I'm not so sure. If dicts or classes are used for configuration
or informational purposes, I prefer them to be locked down.

An example of the first is the decimal context, where it was possible
to write context.emax = 9 instead of context.Emax = 9 without getting
an error. This is an easy mistake to make and can be hard to track
down in a large program.

The mistake here is maybe less likely, but I agree with Georg that
it's a case for a read-only dict/dictproxy.

--
nosy: +skrah
status: pending - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-11-13 Thread Stefan Krah

Changes by Stefan Krah stefan-use...@bytereef.org:


--
title: re.grupindex available for modification and continues to work, having 
incorrect data inside it - re.groupindex available for modification and 
continues to work, having incorrect data inside it

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-11-13 Thread Éric Araujo

Éric Araujo added the comment:

I propose using a MappingProxy type in 3.4 and add an example to the docs for 
stable versions.

--
resolution: invalid - 
stage:  - needs patch
versions: +Python 2.7, Python 3.3, Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-11-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Copy or proxy may affect performance.  We will need to make benchmarks to see 
how much.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-11-12 Thread Eric Snow

Changes by Eric Snow ericsnowcurren...@gmail.com:


--
nosy: +eric.snow

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-03-14 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Looks like a case for a read-only dict/dictproxy :)

--
nosy: +georg.brandl, haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-03-14 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


--
nosy: +gvanrossum

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-03-13 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

 I can get code from anywhere
I am afraid I don’t understand.  Could you start again and explain what bug you 
ran into, i.e. what behavior does not match what the docs say?  At present this 
report looks like it is saying “when I put random things in an internal data 
structures then bad things happen”, and I don‘t think Python promises to not 
break when people do random editions to internal data structures.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-03-13 Thread py.user

py.user port...@yandex.ru added the comment:

I take someone's code
make tests for its behavior
all tests say the code is working
I continue to write the code
make tests for its behavior
all tests say the code is working
I install it somewhere and it crashes

now it is depending on the cache, when this exception is raised

Éric Araujo wrote:
and I don‘t think Python promises to not break when people do random editions

when people do something wrong, python should raise an exception

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-03-12 Thread Matthew Barnett

Matthew Barnett pyt...@mrabarnett.plus.com added the comment:

The re module creates the dict purely for the benefit of the user, and as it's 
a normal dict, it's mutable.

An alternative would to use an immutable dict or dict-like object, but Python 
doesn't have such a class, and it's probably not worth writing one just for 
this use-case.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-03-12 Thread py.user

py.user port...@yandex.ru added the comment:

Matthew Barnett wrote:
 The re module creates the dict purely for the benefit of the user

this dict affects on regex.sub()

 import re
 p = re.compile(r'abc(?Pndef)')
 p.groupindex
{'n': 1}
 p.groupindex['n'] = 2
 p.sub(r'\gn', 'abcdef')
Traceback (most recent call last):
  File /usr/local/lib/python3.2/sre_parse.py, line 811, in expand_template
literals[index] = s = g(group)
IndexError: no such group

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/local/lib/python3.2/re.py, line 286, in filter
return sre_parse.expand_template(template, match)
  File /usr/local/lib/python3.2/sre_parse.py, line 815, in expand_template
raise error(invalid group reference)
sre_constants.error: invalid group reference


--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-03-12 Thread Matthew Barnett

Matthew Barnett pyt...@mrabarnett.plus.com added the comment:

It appears I was wrong. :-(

The simplest solution in that case is for it to return a _copy_ of the dict.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-03-12 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

But regex.sub is affected only if you manually muck with the dict, right?  If 
so, then it looks like a case of “it hurts when I do this” (the doctor’s reply: 
“Don’t do this.”)

--
nosy: +eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-03-12 Thread py.user

py.user port...@yandex.ru added the comment:

the first message shows how it can work with a broken dict

Éric Araujo wrote:
 But regex.sub is affected only if you manually muck with the dict, right?

I can get code from anywhere

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-03-11 Thread Eric V. Smith

Changes by Eric V. Smith e...@trueblade.com:


--
title: regex.groupindex available for modification and continues to work, 
having incorrect data inside it - re.groupindex available for modification and 
continues to work, having incorrect data inside it

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com