[issue12940] Cmd example using turtle left vs. right doc-bug
New submission from Tim Chase : The Turtle example for the cmd module as documented at http://docs.python.org/py3k/library/cmd.html#cmd-example In the left() method, it calls turtle.right() instead of turtle.left(). Easy fix: /def left/+2s/left/right/ Likely exists in most 3.x documentation. -- assignee: docs@python components: Documentation messages: 143746 nosy: Gumnos, docs@python priority: normal severity: normal status: open title: Cmd example using turtle left vs. right doc-bug type: behavior versions: Python 3.3 ___ Python tracker <http://bugs.python.org/issue12940> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12940] Cmd example using turtle left vs. right doc-bug
Tim Chase added the comment: (duh, sorry, that's the "do_left" method, not the "left" method) -- ___ Python tracker <http://bugs.python.org/issue12940> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12940] Cmd example using turtle left vs. right doc-bug
Tim Chase added the comment: I see the status changed to needs-patch. what do I patch against? -- ___ Python tracker <http://bugs.python.org/issue12940> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12940] Cmd example using turtle left vs. right doc-bug
Tim Chase added the comment: Patch attached. -- keywords: +patch versions: -Python 2.7, Python 3.2 Added file: http://bugs.python.org/file23123/issue12940.diff ___ Python tracker <http://bugs.python.org/issue12940> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8666] Allow ConfigParser.get*() to take a default value
New submission from Tim Chase : Patch to update ConfigParser.py so that the .get* methods can take an optional parameter rather than raising exceptions. Usage: cp = ConfigParser(...) # ... value = cp.get('MySection', 'MyOption', default='some default') i = cp.getint('MySecton', 'MyInt', default=42) f = cp.getfloat('MySection', 'MyF', default=3.14) -- components: Library (Lib) messages: 105333 nosy: Gumnos priority: normal severity: normal status: open title: Allow ConfigParser.get*() to take a default value type: feature request versions: Python 2.6 ___ Python tracker <http://bugs.python.org/issue8666> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8666] Allow ConfigParser.get*() to take a default value
Tim Chase added the comment: For some reason, the diff didn't attach to the previous message. -- ___ Python tracker <http://bugs.python.org/issue8666> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8666] Allow ConfigParser.get*() to take a default value
Tim Chase added the comment: Trying a 3rd time to attach the diff (this time from Safari instead of FF) -- keywords: +patch Added file: http://bugs.python.org/file17264/ConfigParser.diff ___ Python tracker <http://bugs.python.org/issue8666> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8666] Allow ConfigParser.get*() to take a default value
Tim Chase added the comment: Yes, the use-case is the same as a dict.get(key, default) which I frequently use -- so it can be used in things like result = some_function( cp.get('MySection', 'MyValue', default='hello'), cp.getint('MySection', 'MyInt', default=42) ) To write something similar with the current ConfigParser requires a lot more code or an inelegant wrapper (either passing the config-parser object each call, or capturing the parser object in a closure which makes the "def" something repeated): try: mv = cp.get('MySection', 'MyValue') except (NoSectionError, NoOptionError), e: mv = 'hello' try: mi = cp.getint('MySection', 'MyInt') except (NoSectionError, NoOptionError), e: mi = 42 result = some_function(mv, mi) del mv, mi # leaving the namespace as it was before The above can be done in a scattering of wrapper functions, but the addition in stock ConfigParser prevents a lot of duplicate code. This is the fourth project in which I've used the ConfigParser and have reached for a default value in every one of them, to be frustrated by the lack. The old-style "raise ValueError" you mention was the original code (just indented), but I've changed it to the preferred format. For the dangling close-paren or "):" on its own line, I tend to do it for the same reason a trailing comma is allowed/encouraged in lists/tuples/dicts/param lists, so it's easy to add further comma-separated entries without giving cluttered diffs. The source against which I'm patching has several dangling close-parens already (search for "^\s*)" to find the calls to re.compile). I pulled down the branches/py3k and patched against it. (attached) -- Added file: http://bugs.python.org/file17280/configparser.diff ___ Python tracker <http://bugs.python.org/issue8666> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8666] Allow ConfigParser.get*() to take a default value
Tim Chase added the comment: The "raise_on_bad" (I'm ambivalent on the name, but if you come up with a better name, I'd be fine with changing it) allows you to differentiate between an option that isn't provided, and one that is provided, but can't be converted to the specified int/float/boolean type. E.g. [MySection] myFloat = hello if you issue f = cp.getfloat("MySection", "myFloat", default=3.14, raise_on_bad=True) it will raise a ValueError because "hello" can't be converted to a float. However there are other times you want (well, other times *I've* wanted...most cases, in fact) to be able to specify that if there's ANY problem, just return the default: f = cp.getfloat("MySection", "myFloat", default=3.14, raise_on_bad=False) returns f=3.14 (the default). The only crazy side-exception I saw in the code is if you make a "dumb programmer" mistake of f = cp.getfloat("MySection", "myFloat", default="foo", raise_on_bad=False) it may still give you an error or unexpected non-float results because the default isn't what you asked for. The ability to get a valid result back (regardless of section or option presence; or data errors) is most helpful when all you want is the answer to the question "did the user specify a valid value I can use? otherwise, just use the darn default". -- ___ Python tracker <http://bugs.python.org/issue8666> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26362] Approved API for creating a temporary file path
Tim Chase added the comment: As requested by Ben Finney[1], adding my use-case here. I'm attempting to make a hard-link from "a" to "b", but if "b" exists, os.link() will fail with an EEXISTS. I don't want to do os.unlink("b") # power-outage here means "b" is gone os.link("a", "b") I can do something like temp_name = tempfile.mktemp(dir=".") os.link("a", temp_name) try: os.rename(temp_name, "b") # docs guarantee this is atomic except OSError: os.unlink(temp_name) but mktemp() is marked as deprecated. I'm okay with the stray temp-file floating around to clean up in the event of power-loss after the os.link() but before the os.unlink() call, as is new info, not disposing of existing file-names [1] https://mail.python.org/pipermail/python-list/2017-April/721641.html -- nosy: +gumnos ___ Python tracker <http://bugs.python.org/issue26362> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26362] Approved API for creating a temporary file path
Tim Chase added the comment: I do have a workaround thanks to Gregory Ewing https://mail.python.org/pipermail/python-list/2017-May/721649.html which suffices for my particular use-case (generating a link to a file with a unique filename). As my use-case is predominantly for *nix environments, the lack of Windows' os.rename() atomicity is merely a would-be-nice-for-other-people-if-it-was-available. But I'll update my documentation to reflect the edge-case. Thanks, Eryk. -- ___ Python tracker <http://bugs.python.org/issue26362> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16071] fix link to email.message.Message in mailbox docs
Tim Chase added the comment: http://docs.python.org/library/mailbox.html#mailbox.Message still points to mailbox.Message instead of email.Message "A subclass of the email.Message module’s {bad link}Message{/bad link}" Not sure if this is a matter of changes that haven't yet been deployed, or just one that slipped through the cracks. -- nosy: +Gumnos ___ Python tracker <http://bugs.python.org/issue16071> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22167] iglob() has misleading documentation (does indeed store names internally)
Changes by Tim Chase : -- nosy: +Gumnos ___ Python tracker <http://bugs.python.org/issue22167> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22319] mailbox.MH chokes on directories without .mh_sequences
New submission from Tim Chase: If a mailbox.MH() object is created by pointing at a path that exists but doesn't contain a ".mh_sequences" file, it raises an exception upon iteration over .{iter,}items() rather than gracefully assuming that the file is empty. I encountered this by pointing it at a Claws Mail IMAP-cache folder (which claims to store its messages in MH format¹ but it doesn't place a .mh_sequences file in those folders) only to have it raise an exception. To replicate: $ mkdir empty $ python >>> import mailbox >>> for msg in mailbox.MH('empty').values(): pass I suspect this could simply wrap the "f = open(os.path.join(self._path, '.mh_sequences'), 'r')" and following lines in a check to ignore the file if it doesn't exist (returning the empty "results"). ¹ http://www.claws-mail.org/faq/index.php/General_Information#How_does_Claws_Mail_store_mails.3F -- components: Library (Lib) messages: 226197 nosy: gumnos priority: normal severity: normal status: open title: mailbox.MH chokes on directories without .mh_sequences type: behavior versions: Python 2.7, Python 3.1, Python 3.2 ___ Python tracker <http://bugs.python.org/issue22319> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22319] mailbox.MH chokes on directories without .mh_sequences
Changes by Tim Chase : -- keywords: +patch Added file: http://bugs.python.org/file36515/mailbox_mh_sequences.diff ___ Python tracker <http://bugs.python.org/issue22319> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22319] mailbox.MH chokes on directories without .mh_sequences
Changes by Tim Chase : Added file: http://bugs.python.org/file36516/mailbox_mh_sequences_lbyl.diff ___ Python tracker <http://bugs.python.org/issue22319> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22319] mailbox.MH chokes on directories without .mh_sequences
Tim Chase added the comment: I had to tweak the example reproduction code as it seemed to succeed (i.e., fail to demonstrate the problem) in some instances. The same exception occurs, but here's the full original traceback: $ cd /home/tim/.claws-mail/imapcache/mail.example.com/t...@example.com/INBOX/ $ python3 Python 3.2.3 (default, Feb 20 2013, 14:44:27) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import mailbox >>> m = mailbox.MH('.') >>> for msg in m: ... print(msg) ... Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.2/mailbox.py", line 114, in itervalues value = self[key] File "/usr/lib/python3.2/mailbox.py", line 78, in __getitem__ return self.get_message(key) File "/usr/lib/python3.2/mailbox.py", line 1019, in get_message for name, key_list in self.get_sequences().items(): File "/usr/lib/python3.2/mailbox.py", line 1128, in get_sequences f = open(os.path.join(self._path, '.mh_sequences'), 'r') IOError: [Errno 2] No such file or directory: '/home/tim/.claws-mail/imapcache/mail.example.com/t...@example.com/INBOX/.mh_sequences' -- ___ Python tracker <http://bugs.python.org/issue22319> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25259] readline macros can segfault Python
New submission from Tim Chase: Attempting to use a readline macro (use "C-x (" to start recording, "C-x )" to stop recording, and "C-x e" to playback) with more than one newline in it will cause a segfault. The behavior also presents in the [`rlwrap` tool](https://github.com/hanslub42/rlwrap/issues/36) but not in `bash`. I've tested and reproduced with Python 2.[4-6] and 3.4, but I don't see any similar bug-reports that would suggest that the problem doesn't also exist in all 3.x series releases. To reproduce, in a `readline`-enabled Python: $ python … >>> import cmd >>> cmd.Cmd().cmdloop() (Cmd) # do "C-x ( C-x ) C-x e" and it segfaults The author of `rlwrap` is working to create a minimum working example, and I'm not sure whether this is a problem with the underlying `libreadline` or just how it's being used by `rlwrap` and Python. -- components: Library (Lib) messages: 251800 nosy: gumnos priority: normal severity: normal status: open title: readline macros can segfault Python type: crash versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6 ___ Python tracker <http://bugs.python.org/issue25259> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com