[issue43323] UnicodeEncodeError: surrogates not allowed when parsing invalid charset

2022-03-26 Thread Anders Kaseorg
Anders Kaseorg added the comment: It could and does, as quoted in my original report. Content-Type: text/plain; charset*=utf-8”''utf-8%E2%80%9D That’s a U+201D right double quotation mark. This is not a valid charset for the charset of course, but it seems like the code was intended

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2022-01-12 Thread Anders Kaseorg
Anders Kaseorg added the comment: > While optparse that it isn't being developed further, therebut will not > be taken away. IIRC the reason for this was that it too had become > difficult to build out and that is what necessitated the creation of > argparse -- there wasn't clea

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2021-12-26 Thread Anders Kaseorg
Anders Kaseorg added the comment: If argparse will not be developed further to fix this bug, then we should undo the deprecation of optparse in the documentation (https://bugs.python.org/issue37103), since the stated justification for that deprecation was that optparse will not be developed

[issue44680] Reference cycles from a WeakKeyDictionary value to its key aren’t collected

2021-07-19 Thread Anders Kaseorg
Anders Kaseorg added the comment: > extra_states[o] = ExtraState(obj) (Typo for extra_states[obj] = ExtraState(obj), obviously.) -- ___ Python tracker <https://bugs.python.org/issu

[issue44680] Reference cycles from a WeakKeyDictionary value to its key aren’t collected

2021-07-19 Thread Anders Kaseorg
New submission from Anders Kaseorg : Because WeakKeyDictionary unconditionally maintains strong references to its values, the garbage collector fails to collect a reference cycle from a WeakKeyDictionary value to its key. For example, the following program unexpectedly leaks memory: from

[issue43323] UnicodeEncodeError: surrogates not allowed when parsing invalid charset

2021-02-25 Thread Anders Kaseorg
New submission from Anders Kaseorg : We ran into a UnicodeEncodeError exception using email.parser to parse this email <https://lists.cam.ac.uk/pipermail/cl-isabelle-users/2021-February/msg00135.html>, with full headers available in the raw archive <https://lists.cam.ac.uk/pip

[issue37103] Undo deprecation of optparse

2019-05-30 Thread Anders Kaseorg
New submission from Anders Kaseorg : The optparse library is currently marked in the documentation as deprecated in favor of argparse. However, argparse uses a nonstandard reinterpretation of Unix command line grammars that makes certain arguments impossible to express, and causes scripts

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2018-12-12 Thread Anders Kaseorg
Anders Kaseorg added the comment: porton: Please don’t steal someone else’s issue to report a different bug. Open a new issue instead. -- title: argparse: add a full fledged parser as a subparser -> argparse does not accept options taking arguments beginning with dash (regress

[issue32601] PosixPathTest.test_expanduser fails in NixOS build sandbox

2018-01-19 Thread Anders Kaseorg
New submission from Anders Kaseorg <ande...@mit.edu>: PosixPathTest.test_expanduser fails in the NixOS build sandbox, where every user has home directory /, so it falls off the end of the for pwdent in pwd.getpwall() loop. nixbld:x:30001:3:Nix build user:/:/noshell nobody:x:65534

[issue8376] Tutorial offers dangerous advice about iterators: “__iter__() can just return self”

2016-10-14 Thread Anders Kaseorg
Anders Kaseorg added the comment: Usui, this is a tutorial intended for beginners. Even if the change from “most” to “built-in” were a relevant one (and I don’t see how it is), beginners cannot possibly be expected to parse that level of meaning out of a single word. The difference between

[issue15429] types.NoneType missing

2012-07-22 Thread Anders Kaseorg
Changes by Anders Kaseorg ande...@mit.edu: -- assignee: docs@python components: Documentation nosy: andersk, docs@python priority: normal severity: normal status: open title: types.NoneType missing type: behavior versions: Python 3.2 ___ Python

[issue15429] types.NoneType missing

2012-07-22 Thread Anders Kaseorg
New submission from Anders Kaseorg ande...@mit.edu: http://docs.python.org/py3k/library/constants.html#None says that None is the sole value type types.NoneType. However, NoneType was removed from the types module with Python 3. -- ___ Python

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2011-12-28 Thread Anders Kaseorg
Anders Kaseorg ande...@mit.edu added the comment: James: That’s not related to this issue. This issue is about options taking arguments beginning with dash (such as a2x --asciidoc-opts --safe, where --safe is the argument to --asciidoc-opts), not positional arguments beginning with dash

[issue12844] Support more than 255 arguments

2011-08-25 Thread Anders Kaseorg
New submission from Anders Kaseorg ande...@mit.edu: This feels like an arbitrary restriction (obvious sequences have been replaced with ‘…’ to save space in this report): zip([0], [1], [2], …, [1999]) File stdin, line 1 SyntaxError: more than 255 arguments especially when this works: zip

[issue12844] Support more than 255 arguments

2011-08-25 Thread Anders Kaseorg
Anders Kaseorg ande...@mit.edu added the comment: I guess the desugaring is slightly more complicated in the case where the original function call already used *args or **kwargs: f(arg0, …, arg999, *args, k0=v0, …, k999=v999, **kwargs) becomes something like f(*((arg0, …, arg999) + args

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2011-03-26 Thread Anders Kaseorg
Anders Kaseorg ande...@mit.edu added the comment: @andersk: Would the restriction to only having flags with a fixed number of arguments be acceptable for your use case? I think that’s fine. Anyone coming from optparse won’t need options with optional arguments. However, FWIW, GNU

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2011-02-06 Thread Anders Kaseorg
Anders Kaseorg ande...@mit.edu added the comment: There are some problems that ‘=’ can’t solve, such as options with nargs ≥ 2. optparse has no trouble with this: parser = optparse.OptionParser() parser.add_option('-a', nargs=2) parser.parse_args(['-a', '-first', '-second']) (Values

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2011-02-06 Thread Anders Kaseorg
Anders Kaseorg ande...@mit.edu added the comment: That would be a good first step. I continue to advocate making that mode the default, because it’s consistent with how every other command line program works[1], and backwards compatible with the current argparse behavior. As far

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2011-02-06 Thread Anders Kaseorg
Anders Kaseorg ande...@mit.edu added the comment: (1) It's only deprecated in the documentation Which is why I suggested un-deprecating it in the documentation. (I want to avoid encouraging programmers to switch away from optparse until this bug is fixed.) # proposed behavior parser

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2010-07-26 Thread Anders Kaseorg
Anders Kaseorg ande...@mit.edu added the comment: I still disagree. You're giving the parser ambiguous input. If a parser sees --foo --bar, and --foo is a valid option, but --bar is not, this is a legitimately ambiguous situation. There is no ambiguity. According to the way that every

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2010-07-26 Thread Anders Kaseorg
Anders Kaseorg ande...@mit.edu added the comment: arguments = *(positional-argument / option) [-- *(positional-argument)] positional-argument = string option = foo-option / bar-option foo-option = --foo string bar-option = --bar Er, obviously positional arguments before the first

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2010-07-23 Thread Anders Kaseorg
Anders Kaseorg ande...@mit.edu added the comment: Note that the negative number heuristic you're complaining about doesn't actually affect your code below. Yes it does: import argparse parser = argparse.ArgumentParser(prog='a2x') parser.add_argument('--asciidoc-opts', ... action

[issue8376] Tutorial offers dangerous advice about iterator s: “__iter__() can just return self”

2010-07-22 Thread Anders Kaseorg
Anders Kaseorg ande...@mit.edu added the comment: I don’t think that small change is good enough, if it is still the case that the only provided example is the dangerous one. It would be easy to clarify the differences between the classes: rl = test.ReverseList('spam') [c for c in rl] ['m

[issue8376] Tutorial offers dangerous advice about iterator s: “__iter__() can just return self”

2010-07-22 Thread Anders Kaseorg
Anders Kaseorg ande...@mit.edu added the comment: Antoine: That’s true. Amaury: See my original bug description (“This is reasonable advice for writing an iterator class, but terrible advice for writing a container class…”), and my other comments. There is nothing wrong with explaining how

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2010-07-22 Thread Anders Kaseorg
New submission from Anders Kaseorg ande...@mit.edu: Porting the a2x program to argparse from the now-deprecated optparse subtly breaks it when certain options are passed: $ a2x --asciidoc-opts --safe gitcli.txt $ ./a2x.argparse --asciidoc-opts --safe gitcli.txt usage: a2x [-h] [--version

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2010-07-22 Thread Anders Kaseorg
Anders Kaseorg ande...@mit.edu added the comment: Though in general I find argparse's default behavior more useful. I’m not sure I understand. Why is it useful for an option parsing library to heuristically decide, by default, that I didn’t actually want to pass in the valid option that I

[issue8376] Tutorial offers dangerous advice about iterator s: “__iter__() can just return self”

2010-04-12 Thread Anders Kaseorg
New submission from Anders Kaseorg ande...@mit.edu: The Python tutorial offers some dangerous advice about adding iterator behavior to a class: http://docs.python.org/tutorial/classes.html#iterators “By now you have probably noticed that most container objects can be looped over using

[issue8376] Tutorial offers dangerous advice about iterator s: “__iter__() can just return self”

2010-04-12 Thread Anders Kaseorg
Anders Kaseorg ande...@mit.edu added the comment: As an experienced Python programmer I am obviously aware that the tutorial is trying to teach how to make an iterator class, not how to make a container class. But the tutorial doesn’t make that *clear*. It should be much more explicit about