[issue41259] Find adverbs is not correct on the documentation

2020-07-09 Thread Peter Otten
Peter Otten <__pete...@web.de> added the comment: While I don't want to start a philosical discussion -- is that really better? Finding adverbs with a regex doesn't work in the general case -- think butterfly, panoply, well -- and the example is meant to illustrate the usage of re.f

[issue39864] IndexError gives wrong axis info

2020-03-05 Thread Peter Otten
Peter Otten <__pete...@web.de> added the comment: This is not a bug (and if it were you would have to report to numpy, not cpython). Consider: >>> import numpy >>> a = numpy.zeros((2,2,2)) >>> a[0,2] Traceback (most recent call last): File "&qu

[issue36561] Python argparse doesn't work in the presence of my custom module

2019-04-08 Thread Peter Otten
Peter Otten <__pete...@web.de> added the comment: That's a bug in your code. You create another ArgumentParser in the toplevel code of preprocess.py. When this module is imported directly or indirectly your script will us this parser to parse the command line first. Minimal example:

[issue36193] Redirected stderr not reset properly when using logging

2019-03-06 Thread Peter Otten
Peter Otten <__pete...@web.de> added the comment: [Andrius] > So it is not possible to consistently manage stderr when it involves > > logging library without explicitly "manage" it? That's what I think, at least from within a script. To me redirect_xxx() always

[issue36191] pubkeys.txt contains bogus keys

2019-03-05 Thread Peter Otten
Change by Peter Otten <__pete...@web.de>: -- nosy: +peter.otten ___ Python tracker <https://bugs.python.org/issue36191> ___ ___ Python-bugs-list

[issue36193] Redirected stderr not reset properly when using logging

2019-03-05 Thread Peter Otten
Peter Otten <__pete...@web.de> added the comment: I see various options to address this. (1) Change basicConfig() to use __stderr__ instead of stderr to avoid redirections from within the script. (2) Change your script to call basicConfig() explicitly, before the temporary redirection

[issue35787] shlex.split inserts extra item on backslash space space

2019-01-20 Thread Peter Otten
Peter Otten <__pete...@web.de> added the comment: To me the current shlex behaviour makes sense, and the shell (tested with bash) behaves the same way: $ python3 -c 'import sys; print(sys.argv)' a b ['-c', 'a', 'b'] $ python3 -c 'import sys; print(sys.argv)' a \ b ['-c', 'a', '

[issue35273] 'eval' in generator expression behave different in dict from list

2018-11-18 Thread Peter Otten
Peter Otten <__pete...@web.de> added the comment: You probably saw this is in Python 2.7 where it is the expected behaviour. All versions of Python 3 should produce the NameError. -- nosy: +peter.otten versions: +Python 3.6 -Python 2.7 ___

[issue30952] [Windows] include Math extension in SQlite

2017-11-06 Thread Peter Otten
Peter Otten <__pete...@web.de> added the comment: A possible workaround is to use create_function(): >>> import sqlite3, math >>> db = sqlite3.connect(":memory:") >>> db.execute("select sin(?);", (math.pi,)).fetchone() Traceback (m

[issue31266] attribute error

2017-08-23 Thread Peter Otten
Peter Otten added the comment: You have probably written your own re.py file which shadows the one in the standard library. Once you remove or rename your re.py the error should go away. -- nosy: +peter.otten ___ Python tracker <

[issue31214] os.walk has a bug on Windows

2017-08-15 Thread Peter Otten
Peter Otten added the comment: Read the documentation of os.walk() again. It already walks the complete directory tree starting with src. When you invoke it again by calling your copy_dir() method recursively you will of course see once more the files and directories in the respective

[issue30034] csv reader chokes on bad quoting in large files

2017-04-11 Thread Peter Otten
Peter Otten added the comment: While I don't think that the csv module should second-guess broken input you might consider "fixing" your data on the fly: def close_quote(line): if line.count('"') % 2: line = line.rstrip("\n") + '"\n' return li

[issue16623] argparse help formatter does not honor non-breaking space

2017-01-17 Thread Peter Otten
Changes by Peter Otten <__pete...@web.de>: -- nosy: +peter.otten ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue16623> ___ __

[issue29290] argparse breaks long lines on NO-BREAK SPACE

2017-01-17 Thread Peter Otten
Changes by Peter Otten <__pete...@web.de>: -- nosy: +peter.otten ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29290> ___ __

[issue29287] IDLE needs syntax highlighting for f-strings

2017-01-17 Thread Peter Otten
Changes by Peter Otten <__pete...@web.de>: -- nosy: +peter.otten ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29287> ___ __

[issue28969] fnmatch is not threadsafe

2016-12-15 Thread Peter Otten
Peter Otten added the comment: Here's another way to reproduce the error. The problem seems to be in the C implementation of _lru_cache_wrapper() / bounded_lru_cache_wrapper(). $ cat test.py import functools import threading import time @functools.lru_cache(maxsize=2) def f(v): time.sleep

[issue27468] Erroneous memory behaviour for objects created in another thread

2016-07-08 Thread Peter Otten
Peter Otten added the comment: Your code relies on the assumption that when the lambda is invoked the global t is still bound to the Thread instance you are starting. It seems that this is not always the case, and I don't see why it should be guaranteed either. I don't know whether it's a good

[issue26126] Possible subtle bug when normalizing and str.translate()ing

2016-01-15 Thread Peter Otten
Peter Otten added the comment: There seems to be a connection to hash randomization. I consistently get $ PYTHONHASHSEED=1 python3.6 ./normbug.py BUG ('The aenid oevre', '!=', 'The AEnid oevre') $ PYTHONHASHSEED=0 python3.6 ./normbug.py OK ('The AEnid oevre', '==', 'The AEnid oevre

[issue26126] Possible subtle bug when normalizing and str.translate()ing

2016-01-15 Thread Peter Otten
Peter Otten added the comment: Not a bug. In your XFORMS dict you have >>> ord("Æ") == 0xC6 True Whether the value of "Æ" or 0xC6 is used by str.maketrans() depends on the order of the dict entries which in turn is determined by the keys' hash. Remove one

[issue25999] Add support of native number in bin()

2016-01-03 Thread Peter Otten
Peter Otten added the comment: How would you disambiguate -1 and (for example) 2**64-1 on a 64-bit machine? Python's int is not limited to a specific number of bits. -- nosy: +peter.otten ___ Python tracker <rep...@bugs.python.org>

[issue24787] csv.Sniffer guesses M instead of \t or , as the delimiter

2015-08-04 Thread Peter Otten
Peter Otten added the comment: The sniffer actually changes its mind in the fourth line: Python 3.4.0 (default, Jun 19 2015, 14:20:21) [GCC 4.8.2] on linux Type help, copyright, credits or license for more information. import csv csv.Sniffer().sniff(\ ... Invoice File,Credit Memo,Amount

[issue16669] Docstrings for namedtuple

2015-04-27 Thread Peter Otten
Peter Otten added the comment: Here's a variant that builds on your code, but makes for a nicer API. Single-line docstrings can be passed along with the attribute name, and with namedtuple.with_docstrings(... all info required to build the class ...) from a user perspective the factory looks

[issue23639] Not documented special names

2015-03-11 Thread Peter Otten
Changes by Peter Otten __pete...@web.de: -- nosy: +peter.otten ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23639 ___ ___ Python-bugs-list

[issue23495] The writer.writerows method should be documented as accepting any iterable (not only a list)

2015-03-07 Thread Peter Otten
Changes by Peter Otten __pete...@web.de: -- nosy: +peter.otten ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23495 ___ ___ Python-bugs-list

[issue23551] IDLE to provide menu options for using PIP

2015-03-07 Thread Peter Otten
Changes by Peter Otten __pete...@web.de: -- nosy: +peter.otten ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23551 ___ ___ Python-bugs-list

[issue22760] re.sub does only first 16 replacements if re.S is used

2014-10-29 Thread Peter Otten
Peter Otten added the comment: This is not a bug; the signature of re.sub() is sub(pattern, repl, string, count=0, flags=0) and the fourth argument thus the 'count' delimiting the number of substitutions that you accidentally specify as import re re.S 16 I recommend that you use a keyword

[issue22240] argparse support for python -m module in help

2014-08-21 Thread Peter Otten
Changes by Peter Otten __pete...@web.de: -- nosy: +peter.otten ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22240 ___ ___ Python-bugs-list

[issue5950] Make zipimport work with zipfile containing comments

2014-05-28 Thread Peter Otten
Changes by Peter Otten __pete...@web.de: -- nosy: +peter.otten ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5950 ___ ___ Python-bugs-list mailing

[issue21553] Behaviour of modules depends on how they where imported

2014-05-22 Thread Peter Otten
Peter Otten added the comment: Here's a simpler demo for what I believe you are experiencing: $ mkdir package $ cd package/ $ touch __ini__.py module.py $ export PYTHONPATH=.. $ python3 Python 3.3.2+ (default, Feb 28 2014, 00:52:16) [GCC 4.8.1] on linux Type help, copyright, credits or license

[issue21177] ValueError: byte must be in range(0, 256)

2014-04-08 Thread Peter Otten
Peter Otten added the comment: As every beginner will learn about (and probably overuse) range() pretty soon I think it's OK to use that form. The math-inspired notation [0, 255] may be misinterpreted as a list. You also lose the consistency of preferring half-open intervals everywhere

[issue20823] Clarify copyreg.pickle() documentation

2014-03-02 Thread Peter Otten
New submission from Peter Otten: The documentation for copyreg.pickle(type, function, constructor=None) has the sentence TypeError will be raised if *object* is a class or *constructor* is not callable. It's not clear to me what object refers to. I believe it refers to the first arg

[issue20823] Clarify copyreg.pickle() documentation

2014-03-02 Thread Peter Otten
Changes by Peter Otten __pete...@web.de: -- keywords: +patch Added file: http://bugs.python.org/file34263/copyreg.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20823

[issue20805] Error in 3.3 Tutorial

2014-02-28 Thread Peter Otten
Peter Otten added the comment: No, that's not an error. Given a class MyClass and an instance x of that class class MyClass: ... def f(self): return 42 ... x = MyClass() you usually invoke a method like so: x.f() 42 But it is also possible to break that in two steps (1) get the bound

[issue20804] Sentinels identity lost when pickled (unittest.mock)

2014-02-28 Thread Peter Otten
Peter Otten added the comment: From looking at the sentinel code it appears a sentinel's identity is controlled by its name alone, i. e. sentinel.foo is sentinel.foo If that's the desired behaviour it is well possible to make that indentity survive pickling. I have attached a demo script

[issue20804] Sentinels identity lost when pickled (unittest.mock)

2014-02-28 Thread Peter Otten
Peter Otten added the comment: I have no experience with unittest.mock, so I'm in no position to contradict... Vlastimil, could you give your use case? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20804

[issue20791] copy.copy(bytes) is slow

2014-02-27 Thread Peter Otten
Peter Otten added the comment: Assuming that the current behaviour is by accident here's a patch that adds the bytes type to the _copy_dispatch registry. -- keywords: +patch nosy: +peter.otten Added file: http://bugs.python.org/file34244/copy_bytes.patch

[issue20794] ImportError: Bad magic number in .pyc file

2014-02-27 Thread Peter Otten
Peter Otten added the comment: This is expected. You cannot run/import 2.6 .pyc files in python 2.7 because the file format has changed. $ echo 'print hello' tmp.py $ python2.6 -c 'import tmp' hello $ rm tmp.py $ python2.7 -c 'import tmp' Traceback (most recent call last): File string

[issue20791] copy.copy(bytes) is slow

2014-02-27 Thread Peter Otten
Peter Otten added the comment: I did sign today (and received the confirmation email). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20791

[issue20714] Allow for ]] in CDATA in minidom

2014-02-24 Thread Peter Otten
Peter Otten added the comment: Perhaps a look at the competition is still in order: Java silently breaks such an invalid CDATA in two, as suggested. http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.htm says No lexical check is done on the content of a CDATA section

[issue20742] 2to3 zip fixer doesn't fix for loops.

2014-02-23 Thread Peter Otten
Peter Otten added the comment: Hm, I would expect that in 99 times out of 100 the extra list(...) would be removed in a manual step following the automated conversion. I'd really like to see the non-contrived example with a justified use of this evil side effect ;) -- nosy

[issue20714] Allow for ]] in CDATA in minidom

2014-02-23 Thread Peter Otten
Changes by Peter Otten __pete...@web.de: -- nosy: +peter.otten ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20714 ___ ___ Python-bugs-list

[issue20729] mailbox.Mailbox does odd hasattr() check

2014-02-22 Thread Peter Otten
Peter Otten added the comment: Do you expect many use cases that rely on items(), keys(), and values() being lists? Maybe it would be acceptable to make these lazy in 3.5, but keep the iterXXX() variants as aliases indefinitely. -- nosy: +peter.otten

[issue20587] sqlite3 converter not being called

2014-02-11 Thread Peter Otten
Peter Otten added the comment: Are you sure that the converter is called in Python 2.5? I've looked into the source (Modules/_sqlite/cursor.c), and if I understand the code correctly it uses the sqlite3_column_decltype() function from the sqlite3 API to determine the column type. So Python

[issue20004] csv.DictReader classic class has a property with setter

2013-12-17 Thread Peter Otten
New submission from Peter Otten: I ran into this when trying to trigger rereading the column names with $ cat tmp.csv alpha,beta 1,2 gamma,delta,epsilon 3,4,5 $ python Python 2.7.2+ (default, Jul 20 2012, 22:15:08) [GCC 4.6.1] on linux2 Type help, copyright, credits or license for more

[issue20004] csv.DictReader classic class has a property with setter

2013-12-17 Thread Peter Otten
Peter Otten added the comment: Setting the fieldnames attribute of an existing DictReader is not documented. Eric, there is no need for an enhancement (other than for the documentation) as this already works in Python 3 where newstyle classes are the default. The heart of the bug is really

[issue20004] csv.DictReader classic class has a property with setter

2013-12-17 Thread Peter Otten
Peter Otten added the comment: The proposed patch looks fine to me. And for the record, I don't think setting fieldnames should be promoted in the 3.x documentation. Along the lines of Eric's suggestion I should have written something like import csv with open(tmp.csv) as f: ... for i

[issue19808] IDLE applies syntax highlighting to user input in its shell

2013-11-30 Thread Peter Otten
Peter Otten added the comment: I think the prompt can easily be treated differently because it is written to stderr. I don't see a difference for user input between input() and raw_input() on Linux with Python 2.7.2+ -- syntax-highlighting is applied to both

[issue19808] IDLE applys syntax highlighting to user input in its shell

2013-11-27 Thread Peter Otten
New submission from Peter Otten: For example when you type input(What shall I do? ) Run for your life! in its shell window IDLE shows the 'for' as if it were a keyword. The same happens if you run a script that requires user interaction. -- components: IDLE messages: 204566 nosy

[issue19808] IDLE applies syntax highlighting to user input in its shell

2013-11-27 Thread Peter Otten
Changes by Peter Otten __pete...@web.de: -- title: IDLE applys syntax highlighting to user input in its shell - IDLE applies syntax highlighting to user input in its shell ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19808

[issue19657] List comprehension conditional evaluation order seems backwards

2013-11-19 Thread Peter Otten
Peter Otten added the comment: I believe you are misinterpreting what you are seeing. Empty lines read from a file do not produce an empty string, you get \n instead which is true in a boolean context. Try [line.split()[0] for line in lines if line.strip() and not line.startswith(#)] or add

[issue19528] logger.config.fileConfig cant cope with files starting with an 'r' on windows

2013-11-08 Thread Peter Otten
Peter Otten added the comment: Simon, in your code you build the config file with '''... args=('{0}', 'a', 131072, 10) ... '''.format(filename) The logging module uses eval() to process the args tuple, and a filename containing a bashlash will not roundtrip that way. Have a look at the .conf

[issue19210] Unicode Objects in Tuples

2013-10-09 Thread Peter Otten
Peter Otten added the comment: Be aware that for a 1-tuple the trailing comma is mandatory: print (uäöü) # this is a string despite the suggestive parens äöü print (uäöü,) # this is a tuple (u'\xe4\xf6\xfc',) -- nosy: +peter.otten ___ Python

[issue18892] sqlite3, valued records not persisted, default ones are

2013-08-31 Thread Peter Otten
Peter Otten added the comment: David means you should replace the line conn.commit in your script which does not invoke the method with conn.commit() Side note: as long as you are a newbie it is a good idea to ask on the python mailing list first before adding a report to the bug tracker

[issue18788] Proof of concept: implicit call syntax

2013-08-20 Thread Peter Otten
Peter Otten added the comment: a bare expression is not call Wouldn't that silently swallow a lot of bare print statements? -- nosy: +peter.otten ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18788

[issue18219] csv.DictWriter is slow when writing files with large number of columns

2013-08-15 Thread Peter Otten
Peter Otten added the comment: Note that set operations on dict views work with lists, too. So the only change necessary is to replace wrong_fields = [k for k in rowdict if k not in self.fieldnames] with wrong_fields = rowdict.keys() - self.filenames (A backport to 2.7 would need to replace

[issue17020] random.random() generating values = 1.0

2013-01-23 Thread Peter Otten
Peter Otten added the comment: This could be a duplicate of issue14591. -- nosy: +peter.otten ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17020

[issue15545] sqlite3.Connection.iterdump() does not work with row_factory = sqlite3.Row

2012-08-06 Thread Peter Otten
Peter Otten added the comment: Here's a minimal fix that modifies the sql in sqlite3.dump._iterdump() to sort the tables by name. It is then no longer necessary to sort the resultset in Python for the unit tests to pass. -- keywords: +patch nosy: +peter.otten Added file: http

[issue15074] Strange behaviour of python cmd module. (Ignores slash)

2012-06-15 Thread Peter Otten
Peter Otten __pete...@web.de added the comment: Not a python bug. You are ommitting an important detail of the stackoverflow example in your code: # we want to treat '/' as part of a word, so override the delimiters readline.set_completer_delims(' \t\n;') Please turn to the Python mailing

[issue14638] pydoc error on instance of a custom class

2012-04-21 Thread Peter Otten
Peter Otten __pete...@web.de added the comment: Patch upload, second attempt. -- keywords: +patch nosy: +peter.otten Added file: http://bugs.python.org/file25298/render_doc.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org

[issue14612] Crash after modifying f_lineno

2012-04-18 Thread Peter Otten
Peter Otten __pete...@web.de added the comment: frame_setlineno() doesn't keep track of with blocks. Here's a patch. -- keywords: +patch nosy: +potten Added file: http://bugs.python.org/file25258/frame_setlineno.patch ___ Python tracker rep

Re: [issue14591] Value returned by random.random() out of valid range

2012-04-16 Thread Peter Otten
Dave Reid wrote: New submission from Dave Reid seabass...@gmail.com: A particular combination of seed and jumpahead calls seems to force the MT generator into a state where it produces a random variate that is outside the range 0-1. Problem looks like it might be in

[issue13510] Clarify that readlines() is not needed to iterate over a file

2011-11-30 Thread Peter Otten
New submission from Peter Otten __pete...@web.de: I've been looking at code on the tutor mailing list for some time, and for line in file.readlines(): ... is a common idiom there. I suppose this is because the readlines() method is easily discoverable while the proper way (iterate over

[issue12888] html.parser.HTMLParser.unescape works only with the first 128 entities

2011-09-03 Thread Peter Otten
Peter Otten __pete...@web.de added the comment: The unescape() method uses re.sub(regex, sub, re.ASCII), but the third argument is count, not flags. Fix is easy: use re.sub(regex, sub, flags=re.ASCII). -- keywords: +patch nosy: +potten Added file: http://bugs.python.org/file23092

[issue7764] Doc for itertools recipe consume is complicated and less efficient

2010-01-23 Thread Peter Otten
Peter Otten __pete...@web.de added the comment: As noted on comp.lang.python the implementation can be simplified to def consume(items, n): next(islice(items, n, n), None) When I suggested the above I wasn't aware that consume(items, None) should exhaust the entire iterator

[issue5832] os.path.walk fails to descend into a directory whose name ends with a space

2009-04-24 Thread Peter Otten
Peter Otten __pete...@web.de added the comment: Is BBDO Atlanta a symbolic link?. These are skipped by os.path.walk(). (The behaviour of os.walk() can be specified with the followsymlinks argument.) -- nosy: +potten ___ Python tracker rep

[issue2527] Pass a namespace to timeit

2008-04-02 Thread Peter Otten
Peter Otten [EMAIL PROTECTED] added the comment: Alexander, I'm fine with a more specific argument name. ns was what the Timer already used internally. Antoine, from __main__ import name1, ..., nameN works fine on the command line, but inside a function you'd have to declare the names you

[issue2527] Pass a namespace to timeit

2008-04-01 Thread Peter Otten
New submission from Peter Otten [EMAIL PROTECTED]: I'd like to suggest a different approach than the one taken in rev. 54348 to improve timeit's scripting interface: allow passing it a namespace. Reasons: - It has smaller overhead for functions that take an argument: def f(a): pass