[issue16563] re.match loops forever on simple regexp
Mark Dickinson added the comment: Closing as a duplicate of issue 1662581. -- nosy: +mark.dickinson resolution: - duplicate status: open - closed superseder: - the re module can perform poorly: O(2**n) versus O(n**2) ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16563 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1662581] the re module can perform poorly: O(2**n) versus O(n**2)
Mark Dickinson added the comment: Given the number of times this comes up, I think it's a least worth an upgrade from 'low' priority to 'normal' priority. -- priority: low - normal versions: +Python 3.4 -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1662581 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16560] Python sighandlers delayed for no reason
Zdenek Pavlas added the comment: This patch isn't safe Yes, it's broken. Does not work unless thread support was enabled, and locking initialized. There are probably other bugs, too. Not meant to be included, really. But IMO the correct implementation should work along these lines. the reason why signal handlers are called synchronously from the main loop is because you can't call arbitrary called on behalf of a signal handler: the must be async safe. Could you elaborate, please? Suppose Python has called a C module. From Python's POV, an async signal is no different from a synchronous C=Python callback. Both are safe. The proper way to do that would be to have a thread dedicated to signal management (like the Java VM does). Please, don't. Python is bloated enough already. This patch is invalid (as is the issue). signal.alarm() and ctrl-c not working in modules is not a valid issue? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16560 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16563] re.match loops forever on simple regexp
Mark Dickinson added the comment: @lpd: you may want to look at the 'regex' module on PyPI [1] to see if it solves your problems. The idea is that some form of this should eventually go into the standard library, but we've been lacking volunteers for the huge code review task involved. [1] http://pypi.python.org/pypi/regex. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16563 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2636] Adding a new regex module (compatible with re)
Changes by Mark Dickinson dicki...@gmail.com: -- versions: +Python 3.4 -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2636 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16560] Python sighandlers delayed for no reason
Charles-François Natali added the comment: the reason why signal handlers are called synchronously from the main loop is because you can't call arbitrary called on behalf of a signal handler: the must be async safe. Could you elaborate, please? Suppose Python has called a C module. From Python's POV, an async signal is no different from a synchronous C=Python callback. Both are safe. No. Here, safe doesn't have anything to do with Python bytecode, or thread-safety. In C, you cannot call arbitrary code from a signal handler, the code must be async-safe (let's say reentrant): for example, if you call malloc() from within a signal handler, you can get a deadlock or a crash if the signal was received while the process was in the middle of an malloc() call. See https://www.securecoding.cert.org/confluence/display/seccode/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlersfor example. So the bottom line is that *you can't call Python code from within a signal handler*. The proper way to do that would be to have a thread dedicated to signal management (like the Java VM does). Please, don't. Python is bloated enough already. This patch is invalid (as is the issue). signal.alarm() and ctrl-c not working in modules is not a valid issue? Yes it is, but I don't think it can be solved without resorting to a dedicated signal management thread (which would also have the nice side effect of avoiding EINTR-related errors). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16560 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4945] json checks True/False by identity, not boolean value
anatoly techtonik added the comment: On Tue, Nov 27, 2012 at 12:15 AM, Ezio Melotti rep...@bugs.python.orgwrote: I'm not sure the documentation should be changed. While boolean values are accepted, user should prefer True/False, so the fact that you can pass other things shouldn't be documented/advertized IMHO. I'd raise that question on python-dev. The patch has a couple of other changes that could be included though. Yes, things that fall out of scope of this report should go into other reports. Otherwise we'll chat here for ages. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4945 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11175] allow argparse FileType to accept encoding and errors arguments
Lucas Maystre added the comment: OK, I'll give it a try. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11175 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4945] json checks True/False by identity, not boolean value
Mark Dickinson added the comment: user should prefer True/False I disagree: I don't see any reason why the normal duck-typing rules shouldn't hold here. So +1 for the documentation changes from me. -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4945 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16560] Python sighandlers delayed for no reason
Zdenek Pavlas added the comment: for example, if you call malloc() from within a signal handler, you can get a deadlock or a crash if the signal was received while the process was in the middle of an malloc() call. Thanks, I see the problem. malloc() implements locking (when threads are enabled), but does not mask signals. When re-entered, this deadlocks. -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16560 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time
Danilo Bargen added the comment: I disagree, I think this bug should be reopened and fixed. A use case that I just ran into: I'm using a Django form with time fields that aren't required, but that are only valid in combination (if there's a open time there has to be a close time). if not (self.closed or (self.open_time and self.close_time )): raise ValidationError(Invalid times) This leads to a Validation Error when using the times 12:00 and 00:00. Of course, this case is debatable and can be worked around by using `self.open is not None and self.close is not None`, but there are even more problems when using the times inside the template. I'm using the following widespread pattern inside my templates: pClose time: {{ close_time|default:- }}/p The default filter used in this case displays the string - if the value on the left side of the | symbol evaluates to False. That makes sense in almost all of the cases. In the case of the `datetime.time(0, 0)` object, the default value is displayed, even though `datetime.time(0, 0).__str__()` results in a valid string (in this case '00:00:00'). (By the way, through these experiments I also found a bug in Django's date formatting template function caused by this inconsistency, which I will report separately.) I agree that casting time objects to a boolean value doesn't make much sense. But especially because of that, inconsistencies in the resulting boolean value should NOT exist. Yet another argument for this is that in many regions midnight isn't considered 00:00, but 24:00, which would obviously not evaluate to False. Please fix this. Otherwise it will lead to a whole lot of weird bugs in software using the datetime library. -- nosy: +gwrtheyrn ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13936 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16564] email.generator.BytesGenerator fails with bytes payload
New submission from Alexander Kruppa: I'm trying to use the email.* functions to craft HTTP POST data for file upload. Trying something like filedata = open(data, rb).read() postdata = MIMEMultipart() fileattachment = MIMEApplication(filedata, _encoder=email.encoders.encode_noop) postdata.attach(fileattachment) fp = BytesIO() g = BytesGenerator(fp) g.flatten(postdata, unixfrom=False) fails with Traceback (most recent call last): File ./minetest.py, line 30, in module g.flatten(postdata, unixfrom=False) File /usr/lib/python3.2/email/generator.py, line 91, in flatten self._write(msg) File /usr/lib/python3.2/email/generator.py, line 137, in _write self._dispatch(msg) File /usr/lib/python3.2/email/generator.py, line 163, in _dispatch meth(msg) File /usr/lib/python3.2/email/generator.py, line 224, in _handle_multipart g.flatten(part, unixfrom=False, linesep=self._NL) File /usr/lib/python3.2/email/generator.py, line 91, in flatten self._write(msg) File /usr/lib/python3.2/email/generator.py, line 137, in _write self._dispatch(msg) File /usr/lib/python3.2/email/generator.py, line 163, in _dispatch meth(msg) File /usr/lib/python3.2/email/generator.py, line 192, in _handle_text raise TypeError('string payload expected: %s' % type(payload)) TypeError: string payload expected: class 'bytes' This is because BytesGenerator._handle_text() expects str payload in which byte values that are non-printable in ASCII have been replaced by surrogates. The example above creates a bytes payload, however, for which super(BytesGenerator,self)._handle_text(msg) = Generator._handle_text(msg) throws the exception. Note that using any email.encoders other than encode_noop does not really fit the HTTP POST bill, as those define a Content-Transfer-Encoding which HTTP does not know. It would seem better to me to let BytesGenerator accept a bytes payload and just copy that to the output, rather than making the application encode the bytes as a string, hopefully in a way that s.encode('ascii', 'surrogateescape') can invert. E.g., a workaround class I use now does class FixedBytesGenerator(BytesGenerator): def _handle_bytes(self, msg): payload = msg.get_payload() if payload is None: return if isinstance(payload, bytes): self._fp.write(payload) elif isinstance(payload, str): super(FixedBytesGenerator,self)._handle_text(msg) else: # Payload is neither bytes not string - this can't be right raise TypeError('bytes or str payload expected: %s' % type(payload)) _writeBody = _handle_bytes -- components: Library (Lib) messages: 176476 nosy: Alexander.Kruppa priority: normal severity: normal status: open title: email.generator.BytesGenerator fails with bytes payload type: behavior versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16564 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16564] email.generator.BytesGenerator fails with bytes payload
R. David Murray added the comment: Yes, the way BytesGenerator works is basically a hack to get the email package itself working. Use cases outside the email package were not really considered in the (short) timeframe during which it was implemented. The longer term plan calls for redoing the way payloads are handled to generalize the whole process. I'd like to see this happen for 3.4, but I'm not sure I'm going to have the time to finish the work (I'm hopeful that I will, though). In the meantime, while your suggestion is a good one, I'm ambivalent about applying it as a bug fix. It is on the border between a fix and a feature, since the email package in 3.x hasn't ever supported bytes payloads, only encoded payloads. -- components: +email nosy: +barry, r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16564 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16564] email.generator.BytesGenerator fails with bytes payload
R. David Murray added the comment: Hmm. Let me rephrase that. *Internally* it doesn't support bytes payloads, it encodes bytes payloads as surrogateescaped ascii, as you have oserved. Which is why this is on the borderline, and could possibly be considered a bug fix, because from an external point of view it does support parsing and generating 8bit payloads. I need to give it some thought, and perhaps others will weigh in with opinions. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16564 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11175] allow argparse FileType to accept encoding and errors arguments
Lucas Maystre added the comment: Added some documentation for the patch. Let me know what you think. -- Added file: http://bugs.python.org/file28139/filetype11175.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11175 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4945] json checks True/False by identity, not boolean value
Ezio Melotti added the comment: I don't see any reason why the normal duck-typing rules shouldn't hold here. The rules should apply, the only problem is in the documentation. The documentation here could answer two questions: 1) what should I pass to these args to make them work? 2) can I pass things that are not True/False? For the 1st question the answer is True or False (sure you can pass other things, but if you have to pick two values use these). Regarding the 2nd question I'm not even sure why would anyone ask it. The only case I can think about is someone used to 0/1 instead of True/False but if I wanted to know if they worked, I would, in order: 1) use True/False because I'm sure it works; 2) convert what I have to True/False because I'm sure it works; 3) try what I have and see if it works (and be paranoid because it might break somewhere); 4) read to code to make sure what I have works; 5) read the documentation and see if it mentions values that are not explicitly True/False. Moreover even if I read 'true' instead of 'True' in the docs I wouldn't think it's lowercase so it must accept any true value and not just True/False. IOW the lowercase true only serves to provide a mild reassurance to someone that wants to use something different from True/False, that read the docs expecting to find this reassurance, and that is fine with how mild it is. OTOH is not a big deal, I was just explaining the reasoning behind my position. Two more things though: I looked at the docstring of loads/dumps and I see True, false and is specified; I don't like much the parallel between the lowercase is true and the uppercase default: False. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4945 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16507] Patch selectmodule.c to support WSAPoll on Windows
Changes by Giampaolo Rodola' g.rod...@gmail.com: -- nosy: +giampaolo.rodola ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16507 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16556] Update string.Formatter.vformat documentation to say **kwargs
Roundup Robot added the comment: New changeset d805982336a0 by Ezio Melotti in branch '2.7': #16556: Fix inconsistency between kwds and kwargs. Patch by Taavi Burns. http://hg.python.org/cpython/rev/d805982336a0 New changeset 565c3bbed7d3 by Ezio Melotti in branch '3.2': #16556: Fix inconsistency between kwds and kwargs. Patch by Taavi Burns. http://hg.python.org/cpython/rev/565c3bbed7d3 New changeset ae19d86b71c8 by Ezio Melotti in branch '3.3': #16556: merge with 3.2. http://hg.python.org/cpython/rev/ae19d86b71c8 New changeset c28f593ea0cb by Ezio Melotti in branch 'default': #16556: merge with 3.3. http://hg.python.org/cpython/rev/c28f593ea0cb -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16556 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16556] Update string.Formatter.vformat documentation to say **kwargs
Ezio Melotti added the comment: The patch looked OK, so I committed it. Regarding similar cleanups I think it's OK to do them only if the inconsistency is in the same function. If different functions use kwds or kwargs in different places but they do it consistently, then it doesn't matter. -- assignee: docs@python - ezio.melotti resolution: - fixed stage: - committed/rejected status: open - closed versions: +Python 3.2, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16556 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16556] Update string.Formatter.vformat documentation to say **kwargs
Éric Araujo added the comment: Oh, I had totally missed that the mismatch was between the function signature in the docs and another part of the doc (I thought it was between the real function signature and the doc). Good catch! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16556 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16555] Add es_cu to locale aliases
Éric Araujo added the comment: Ah, ok. Sounds good to me. (I think this can go in stable branches, like other update to registries (e.g. mimetypes), but other core devs may disagree.) -- nosy: +lemburg, loewis title: Add es_cu to locale library. - Add es_cu to locale aliases versions: +Python 3.2, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16555 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4945] json checks True/False by identity, not boolean value
Changes by Serhiy Storchaka storch...@gmail.com: -- nosy: +chris.jerdonek ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4945 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16562] Optimize dict equality test
Martin v. Löwis added the comment: The patch looks good to me. -- nosy: +loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16562 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4555] Smelly exports (global symbols in python not prefixed with Py or _Py)
Martin v. Löwis added the comment: I'd like to focus this issue; it has been open long enough, and deserves to get closed once the original issue is resolved - which was that make smelly reports symbols. I think dmalcolm's patch is quite a good start for that. It may well be that other modules need to be considered - but PLEASE not in this issue. For Unix with shared libraries, the extension modules certainly cause problems, in particular if Python gets embedded in a context (e.g. Apache) that also loads separate copies of the same libraries, and may cause problems if one of our functions collide with some library. However, I see *two* issues falling out of this: one to extend the make smelly target to include extension modules, and the other to then fix the extension modules - preferably with one issue per extension module. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4555 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16333] Trailing whitespace in json dump when using indent
Ezio Melotti added the comment: Do you mean that when indentation is used, the separator only appears on line ends? Apparently: ./python -c 'from json import dumps; print(dumps([[[1,2,3]]*3]*3, indent=2))' -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16333 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16562] Optimize dict equality test
Serhiy Storchaka added the comment: And here is a synthetic microbenchmark: $ ./python -m timeit -s n=10**3; k=2; a={(i,)*k:i for i in range(n)}; b={(i,)*k:i for i in range(n)} a == b Vanilla: 251 usec per loop Patched: 195 usec per loop $ ./python -m timeit -s n=10**3; k=2; a={(i,)*k:i for i in range(n)}; b=dict(a) a == b Vanilla: 116 usec per loop Patched: 58.6 usec per loop The use of tuple keys is quite common. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16562 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4945] json checks True/False by identity, not boolean value
Chris Jerdonek added the comment: On the whole, the patch looks okay to me. I think we should strive for correctness in the documentation where possible. While keeping True would keep the forward implications correct and document the preferred value, there is often an implied assumption (which is sometimes stated) that the negation of the first term does not trigger or guarantee the behavior described in the second term. It is that second implication that would be incorrect in some cases if True is kept (e.g. *check_circular* and *allow_nan*). In cases where both if True and if False are explicitly stated, keeping True and False would mean not documenting certain cases. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4945 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16416] Mac OS X: don't use the locale encoding but UTF-8 to encode and decode filenames
Antoine Pitrou added the comment: Victor, could you please backport to 3.3? -- assignee: ronaldoussoren - haypo nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16416 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16565] Increase Py_AddPendingCall array size
New submission from Felipe Cruz: Current pending calls limit is too small and it can be easily reached in very intensive async file io applications. There is a little hack in pyaio[1] which sleeps if Py_AddPendingCall returns 0 but It's not totally clear to me why the size of pendind calls array is only 32. [1] https://github.com/felipecruz/pyaio -- components: IO messages: 176491 nosy: felipecruz priority: normal severity: normal status: open title: Increase Py_AddPendingCall array size versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16565 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16562] Optimize dict equality test
Changes by STINNER Victor victor.stin...@gmail.com: -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16562 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16464] urllib.request: opener not resetting content-length
Roundup Robot added the comment: New changeset 618ea5612e83 by Andrew Svetlov in branch 'default': Issue #16464: reset Request's Content-Length header on .data change. http://hg.python.org/cpython/rev/618ea5612e83 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16464 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16464] urllib.request: opener not resetting content-length
Andrew Svetlov added the comment: Pushed. Thanks, Alexey. -- versions: +Python 3.4 -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16464 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16464] urllib.request: opener not resetting content-length
Changes by Andrew Svetlov andrew.svet...@gmail.com: -- assignee: - asvetlov resolution: - fixed stage: needs patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16464 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16566] Structure._anonymous_ should not allow strings
New submission from anatoly techtonik: http://docs.python.org/2/library/ctypes.html#ctypes.Structure._anonymous_ An optional sequence that lists the names of unnamed (anonymous) fields. If you feed it a string, such as _offset, it will print a very interesting error: ... File C:\roundup\.\roundup\backends\portalocker.py, line 70, in module class A_OFFSET_UNION(Union): AttributeError: type object '_OFFSET_UNION' has no attribute '_' Considering complexity that ctypes already has, the simple check that _anonymous_ is a sequence (and not a string) will make our lifes easier. -- components: ctypes messages: 176494 nosy: techtonik priority: normal severity: normal status: open title: Structure._anonymous_ should not allow strings versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16566 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16566] Structure._anonymous_ should not allow strings
anatoly techtonik added the comment: s/A_OFFSET_UNION/_OFFSET_UNION/ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16566 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16566] Structure._anonymous_ should not allow strings
anatoly techtonik added the comment: The union definition for the curious: class _OFFSET(Structure): _fields_ = [ ('Offset', DWORD), ('OffsetHigh', DWORD)] class _OFFSET_UNION(Union): _anonymous_ = '_offset' _fields_ = [ ('_offset', _OFFSET), ('Pointer', PVOID)] -- versions: +Python 3.1, Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16566 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16566] Structure._anonymous_ should not allow strings
STINNER Victor added the comment: An optional sequence that lists the names of unnamed (anonymous) fields Yes, it must be a sequence. _anonymous_ = '_offset' This is a string, not a sequence. Just use _anonymous_ = ['_offset']. -- nosy: +haypo resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16566 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16203] Proposal: add re.fullmatch() method
Ezra Berch added the comment: Patch attached. I've taken a slightly different approach than what has been discussed here: rather than define a new fullmatch() function and method, I've defined a new re.FULLMATCH flag for match(). So an example would be re.match('abc','abc',re.FULLMATCH) The implementation is basically what has been discussed here, except done when the regular expression is compiled rather than at the user level. -- keywords: +patch nosy: +ezberch Added file: http://bugs.python.org/file28140/issue16203.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16203 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16566] Structure._anonymous_ should not allow strings
anatoly techtonik added the comment: ctypes should throw proper exception if a string is used instead of sequence. It doesn't do this. -- resolution: invalid - status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16566 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16438] Numeric operator predecence confusing
Ezio Melotti added the comment: I'm still unable to figure out how to do it You could look at Doc/library/unittest.rst, there are some tables that span multiple lines. If you want a newline in the output too I think you have to add a blank line in the cell. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16438 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2537] re.compile(r'((x|y+)*)*') should fail
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16566] Structure._anonymous_ should not allow strings
Meador Inge added the comment: A string *is* a sequence. That is actually part of the problem. Consider a slight variation on the original repro case: class _OFFSET(Structure): ... _fields_ = [ ... ('Offset', c_int), ... ('OffsetHigh', c_int)] ... [70412 refs] class _OFFSET_UNION(Union): ... _anonymous_ = 12 ... _fields_ = [ ... ('_offset', _OFFSET), ... ('Pointer', c_int)] ... Traceback (most recent call last): File stdin, line 1, in module TypeError: _anonymous_ must be a sequence As expected, a TypeError is produced. Now consider the original error: Traceback (most recent call last): File stdin, line 1, in module AttributeError: type object '_OFFSET_UNION' has no attribute '_' This happens because the string sequence '_offset' is iterated and the first item in the iteration is '_', which isn't a field of _OFFSET_UNION. So, the error checking is already there (in the form of PySequence_Fast) and is consistent with the documentation. This should be closed. -- nosy: +meador.inge ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16566 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16438] Numeric operator predecence confusing
Kiet Tran added the comment: That document actually doesn't have any table that spans multiple lines. Here's the html page: http://docs.python.org/dev/library/unittest.html Actually, I already know how to make a table span multiple lines from this stackoverflow page: http://stackoverflow.com/questions/13504595/multi-line-table-cell-in-restructuredtext However, the problem is having the items in different columns match, as it depends on the width of the table, which is not fixed. For example, notice how the table is formatted nicely here: http://imgur.com/y1hLg But if I shrink the width, the formatting just goes wrong: http://imgur.com/Oct9m This is particularly problematic because some elements in the table have long lines. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16438 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5066] IDLE documentation for Unix obsolete/incorrect
Todd Rovito added the comment: Version 2 of the patch change include: -help.txt removed all tabs and replaced with spaces, as suggested by Roger -help.txt re-inserted the section on running IDLE without a subprocess as suggested by Roger -Added a note on line 162 (idle.rst) about how the Python Community standard is to use spaces and not tabs as suggested by ezio -Line 340 (idle.rst) where the Emacs bindings are rendered seemed to work fine on my computer without the spaces but I think ezio is correct spaces should be present so I added them -Line 354 (idle.rst): are restricted to four spaces due to TCL/Tk issues.)s/issues/limitations/ so I replaced issues with limitations Thanks for the feedback Roger and ezio! -- Added file: http://bugs.python.org/file28141/5066IDLEocumentationforUnixObsoleteIncorrectVersion2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5066 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5066] IDLE documentation for Unix obsolete/incorrect
Todd Rovito added the comment: For version 2 of the patch -Line 340 (idle.rst) where the Emacs bindings are rendered seemed to work fine on my computer without the spaces but I think ezio is correct spaces should be present so I added them **SHOULD BE** -Line 340 (idle.rst) where the Emacs bindings are rendered seemed to work fine on my computer without the empty line between entries but I think ezio is correct empty lines should be present so I added empty lines just to be safe -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5066 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16566] Structure._anonymous_ should not allow strings
Nick Coghlan added the comment: Yes, if you pass string when you meant to pass [string], you will often get awful error messages. This is one of the downsides of strings being iterable, but we're not going to add if isinstance(obj, str): throw TypeError(msg) special cases everywhere to address it. It's definitely a wart in Python, but it's one Python developers just have to get used to (and learn to suspect whenever they see a single-character string in an error message). -- nosy: +ncoghlan resolution: - wont fix status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16566 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16562] Optimize dict equality test
Raymond Hettinger added the comment: The patch looks correct. If the tests pass, go ahead and apply it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16562 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15990] solidify argument/parameter terminology
Chris Jerdonek added the comment: Attaching new patch to address Ezio's suggestions on Rietveld. I will also respond to those comments on Rietveld shortly. -- Added file: http://bugs.python.org/file28142/issue-15990-5-default.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15990 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15990] solidify argument/parameter terminology
Chris Jerdonek added the comment: For some reason, Rietveld is erroring out every time I try to reply to one of the comments. So I am pasting the reply below: [Issue in the Rietveld tracker here: http://code.google.com/p/rietveld/issues/detail?id=394 ] On 2012/11/26 22:07:50, ezio.melotti wrote: Note that I took this from the pep. The pep could get the same clarification (unless I made it more confusing than it was). From what I have observed, PEPs tend to be left alone after they are accepted. But that could simply be a misperception on my part. What is the process for updating PEPs and whose approval is needed, etc? In any case, that could be done as part of a separate issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15990 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2927] expose html.parser.unescape
Changes by Martin Panter vadmium...@gmail.com: -- nosy: +vadmium ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2927 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16549] regression: -m json.tool module is broken
Changes by Martin Panter vadmium...@gmail.com: -- nosy: +vadmium ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16549 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16209] add a class str entry to the docs
Chris Jerdonek added the comment: Attaching new patch to address Ezio's suggestions on Rietveld. -- Added file: http://bugs.python.org/file28143/issue-16209-3-default.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16209 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15716] Ability to specify the PYTHONPATH via a command line flag
Brian Curtin added the comment: Colin - it should work in the same way that setting PYTHONPATH as an environment variable would work, e.g., semi-colon is the separator on Windows. -- nosy: +brian.curtin ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15716 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16547] IDLE raises an exception in tkinter after fresh file's text has been rendered
Roger Serwy added the comment: I was able to trigger this problem on 2.7 as well. Changing type to behavior as the core interpreter is not crashing. Lukas, the only way I can trigger the traceback is by closing the editor while the colorizer is still colorizing. Clicking randomly on the editor itself did not trigger the bug. Can you clarify what you meant when you said window receives events (clicks...)? Closing the window place a close-window event on the Tk event queue. Calling .update() causes Tk to process all events in the queue, including callbacks into IDLE. As a result, closing a window can trigger a few different use-after-free conditions. I managed to trigger two of these in the __init__ of PyShellEditorWindow in Lib/idlelib/PyShell.py. The self.io reference can be set to None during EditorWindow.__init__(self, *args) or during self.restore_file_breaks(). The Lib/idlelib/ColorDelegator.py also has a .update() in its recolorize_main loop. -- stage: - needs patch title: IDLE segfaults in tkinter after fresh file's text has been rendered - IDLE raises an exception in tkinter after fresh file's text has been rendered type: crash - behavior versions: +Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16547 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1286] fileinput, StringIO, and cStringIO do not support the with protocol
Eric Snow added the comment: Keep in mind that it's pretty easy to roll your own CM wrapper: @contextlib.contextmanager def closes(file): yield file file.close() Then you can do this: with closes(StringIO()) as test: test.write(hi!) return test.getvalue() This works for 2.5 and up. -- nosy: +eric.snow ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1286 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1286] fileinput, StringIO, and cStringIO do not support the with protocol
Ezio Melotti added the comment: http://docs.python.org/2/library/contextlib.html#contextlib.closing -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1286 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16129] No good way to set 'PYTHONIOENCODING' when embedding python.
Campbell Barton added the comment: patch attached, simply wraps putenv() -- keywords: +patch Added file: http://bugs.python.org/file28144/pyos_putenv.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16129 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16129] No good way to set 'PYTHONIOENCODING' when embedding python.
Christian Heimes added the comment: At first glance your proposed fix looks like an easy hack to get around the issue. However it's not going to work properly. Embedded Python interpreters should isolate themselves from the user's environment. When `Py_IgnoreEnvironmentFlag` is enabled, Py_GETENV() always returns NULL. IMHO we can't get around Py_GetIOEncoding(), Py_SetIOEncoding() and Py_IOEncoding. -- nosy: +christian.heimes ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16129 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16129] No good way to set 'PYTHONIOENCODING' when embedding python.
Nick Coghlan added the comment: Claiming this one, mainly because I want people to largely leave the already hairy initialisation process alone until we get a chance to discuss it at the language summit next year. I plan to write up a comprehensive overview of the initialisation sequence before then, because we need to be figuring out how to *delete* code here, instead of adding even more. -- assignee: - ncoghlan nosy: +ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16129 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12370] Use of super overwrites use of __class__ in class namespace
Eric Snow added the comment: I agree with Benjamin re: __args__ and __kw__. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12370 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10914] Python sub-interpreter test
Changes by Eric Snow ericsnowcurren...@gmail.com: -- nosy: +eric.snow ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10914 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1286] fileinput, StringIO, and cStringIO do not support the with protocol
Eric Snow added the comment: borrowed the time machine did we? ;) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1286 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16499] CLI option for isolated mode
Changes by Nick Coghlan ncogh...@gmail.com: -- nosy: +ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16499 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16567] Implementing .= for variable operator
New submission from Erik VanderWerf: I don't know if this has been suggested before, none of my searches returned anything. Sorry if it has been rejected already. Anyone who has used Python at least a little bit will know that you can use +=, -=, *=, and /= to apply a change to a variable and store it in the same variable in one step. (a = a + 1) == (a += 1) Would it be possible to add a fifth operator, .= (period-equals) to apply a method to a variable in one step? ex: a = SPAM a .= lower() a 'spam' It would make code look a lot better, and easier to write for any longer-named variables. I can see where passing a method of an object by itself would cause an error, but might it be possible for the .= to override this? -- components: None messages: 176519 nosy: yos233 priority: normal severity: normal status: open title: Implementing .= for variable operator type: enhancement versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16567 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12370] Use of super overwrites use of __class__ in class namespace
Nick Coghlan added the comment: From a quick scan of the patch, I suspect the current implementation will also break this code: class Outer: class InnerParent: pass class InnerChild(InnerParent): pass The evaluation of the other args to build_class needs to happen before we enter the new outer scope to fix that. I also agree with the others that this should use hidden variable names for the build_class arguments, rather than __args__ and __kw___. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12370 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15627] Add a method to importlib.abc.SourceLoader for converting source to a code object
Eric Snow added the comment: Sorry, just now digging out of a massive backlog here. The originally proposed name of source_to_code() might be more appropriate than compile_source(). The relationship to compilation is not compulsory and the name/docstring/docs might imply that. If you're not opposed, Brett, I can make the change. Regardless, glad to see this in. :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15627 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13475] Add '-p'/'--path0' command line option to override sys.path[0] initialisation
Eric Snow added the comment: This proposal only affects the initialization of sys.path[0], and not any of the other sys.path entries made by site.py or otherwise. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13475 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com