[issue18744] pathological performance using tarfile

2013-08-14 Thread Ned Deily
Changes by Ned Deily : -- nosy: +lars.gustaebel ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyt

[issue17628] str==str: compare the first character before calling memcmp()

2013-08-14 Thread Raymond Hettinger
Raymond Hettinger added the comment: The dont-compare-first-last patch looks about right. The "if (len == 0) return 1;" shortcut perhaps should be taken out. It makes the common case pay (if only slightly) for the rare case (which of course, never gets predicted). This whole code block gets

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

2013-08-14 Thread Mikhail Traskin
Mikhail Traskin added the comment: > What is the purpose in touching fieldnames [...] Wrapping the fieldnames property and tupleizing it guarantees that fieldnames and _fieldset fields are consistent. Otherwise, having a separate _fieldset field means that someone who is modifying the fieldnam

[issue18744] pathological performance using tarfile

2013-08-14 Thread K Richard Pixley
New submission from K Richard Pixley: There's a problem with tarfile. Write a program to traverse the contents of a modest sized tar archive. Make sure your tar archive is compressed. Then read the tar archive with your program. I'm finding that allowing tarfile to read a compressed archive

[issue18743] References to non-existant "StringIO" module

2013-08-14 Thread Jesús Cea Avión
New submission from Jesús Cea Avión: Doing a "grep StringIO Doc/library/*.rst" shows a handful of references to the old StringIO library. Notably: gzip.rst mailbox.rst tempfile.rst test.rst unittest.mock.rst xml.dom.minidom.rst -- assignee: docs@python components: Documentation message

[issue18698] importlib.reload() does not return the module in sys.modules

2013-08-14 Thread Eric Snow
Eric Snow added the comment: oops. That commit message for 3.3 should have read "imp.reload()". :) -- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed ___ Python tracker _

[issue18698] importlib.reload() does not return the module in sys.modules

2013-08-14 Thread Roundup Robot
Roundup Robot added the comment: New changeset e22e7268e58a by Eric Snow in branch '3.3': issue #18698: ensure importlib.reload() returns the module out of sys.modules. http://hg.python.org/cpython/rev/e22e7268e58a New changeset 1af087712e69 by Eric Snow in branch 'default': Closes issue #18698:

[issue18425] IDLE Unit test for IdleHistory.py

2013-08-14 Thread Terry J. Reedy
Terry J. Reedy added the comment: Moved most initialization to method setUp to prevent cascading of test failures. Added info about History.fetch and FetchTest.fetch_test methods. Added tests for non-cyclic and special behavior and for fetch event wrappers. Coverage is essentially 100%. -

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Ethan Furman
Ethan Furman added the comment: Drat. IntEnum is supposed to be a drop-in replacement for int. I guess I'll have to consider more than just the letter code to decide whether to go with int.__format__ or str.__format__. -- ___ Python tracker

[issue18742] Abstract base class for hashlib

2013-08-14 Thread Christian Heimes
New submission from Christian Heimes: All hashlib types provide a common interfaces but there is no common super class. The patch implements provides hashlib.CryptoHash abstract base class as common virtual class for all hash types. The patch also exposes all internal types of the internal has

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eric V. Smith
Eric V. Smith added the comment: >> In order to avoid that logic, and cause more format specifiers to result in >> str-like behavior, we'll need to implement an __format__ somewhere (IntEnum, >> I guess) that makes the "int or str" decision. > > If this is the way format is supposed to work, t

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Ethan Furman
Ethan Furman added the comment: > In order to avoid that logic, and cause more format specifiers to result in > str-like behavior, we'll need to implement an __format__ somewhere (IntEnum, > I guess) that makes the "int or str" decision. If this is the way format is supposed to work, then I'll

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eric V. Smith
Eric V. Smith added the comment: It's not whether a field width is specified that makes it "empty" or not, it's where there's anything in the format specifier at all. I'm trying to simplify the conversation by using format() instead of str.format(), but I'm not succeeding! Going back to str.f

[issue18677] Enhanced context managers with ContextManagerExit and None

2013-08-14 Thread Nick Coghlan
Nick Coghlan added the comment: I think you make a good case, but I already tried and failed to convince Guido of this in PEP 377 (see http://www.python.org/dev/peps/pep-0377/#rationale-for-change) More importantly, see his quoted concerns in http://mail.python.org/pipermail/python-dev/2009-M

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eli Bendersky
Eli Bendersky added the comment: On Wed, Aug 14, 2013 at 2:38 PM, Eric V. Smith wrote: > > Eric V. Smith added the comment: > > > So what you're saying is that '{:}' is empty, but '{:10}' is not? > > Yes, exactly. The part before the colon says which argument to .format() > to use. The empty str

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eric V. Smith
Eric V. Smith added the comment: > So what you're saying is that '{:}' is empty, but '{:10}' is not? Yes, exactly. The part before the colon says which argument to .format() to use. The empty string there means "use the next one". The part after the colon is the format specifier. In the first

[issue18647] re.error: nothing to repeat

2013-08-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: So what now? Just remove unneeded check? Related issues: issue1633953, issue2537. -- ___ Python tracker ___ _

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Ethan Furman
Ethan Furman added the comment: So what you're saying is that '{:}' is empty, but '{:10}' is not? -- ___ Python tracker ___ ___ Python

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eric V. Smith
Eric V. Smith added the comment: The value of int is always used, except when the format string is empty. PEP 3101 explicitly requires this behavior. "For all built-in types, an empty format specification will produce the equivalent of str(value)." The "built-in type" here refers to int, since

[issue18741] Fix typos/spelling mistakes in Lib/*/*/.py files

2013-08-14 Thread Févry Thibault
New submission from Févry Thibault: Using the same tool described in issue 18705, I fixed more typos. -- assignee: docs@python components: Documentation files: another_typo_patch.diff keywords: patch messages: 195216 nosy: docs@python, iwontbecreative priority: normal severity: normal st

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Ethan Furman
Ethan Furman added the comment: --> class Test(enum.IntEnum): ... one = 1 ... two = 2 ... --> '{}'.format(Test.one) 'Test.one' --> '{:d}'.format(Test.one) '1' --> '{:}'.format(Test.one) 'Test.one' --> '{:10}'.format(Test.one) ' 1' Sometimes the str is used, and sometimes the valu

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eric V. Smith
Changes by Eric V. Smith : -- assignee: -> ethan.furman ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http:/

[issue15428] add "Name Collision" section to argparse docs

2013-08-14 Thread paul j3
Changes by paul j3 : -- nosy: +paul.j3 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/m

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eric V. Smith
Eric V. Smith added the comment: I don't think it's possible for int (PyLong) to handle a decision to format itself as a string. Personally, I'd like this: >>> format(3, 's') Traceback (most recent call last): File "", line 1, in ValueError: Unknown format code 's' for object of type 'int'

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Ethan Furman
Ethan Furman added the comment: What I'm hoping is to get agreement on what the behavior should be (unspecified format codes use str or repr, specified numeric codes use the value), and then persuade folks that int (or PyLong) is where that behavior should be kept (so int is subclass friendly

[issue4749] Issue with RotatingFileHandler logging handler on Windows

2013-08-14 Thread Piotr Dobrogost
Changes by Piotr Dobrogost : -- nosy: +piotr.dobrogost ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://ma

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eric V. Smith
Eric V. Smith added the comment: If IntEnum.__format__ is going to parse the format string, it's a little fragile. For example, say we modify int.__format__ to understand a "Z" presentation type. Who's going to remember to update IntEnum.__format__? For reference, the existing integer formats

[issue18727] test for writing dictionary rows to CSV

2013-08-14 Thread Muhammad Jehanzeb
Muhammad Jehanzeb added the comment: Thanks Antoine, Attached is the updated version of patch using StringIO -- Added file: http://bugs.python.org/file31293/issue18727_v2.patch ___ Python tracker _

[issue18677] Enhanced context managers with ContextManagerExit and None

2013-08-14 Thread Kristján Valur Jónsson
Kristján Valur Jónsson added the comment: "locally visible" is, I think a very misleading term. How is with ignore_error, acquire_resource as r: doo_stuff_with_resource(r) #can be silently skipped any more locally visible than with acquire_resource_ignore_error as r: doo_stuff_with reso

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eli Bendersky
Eli Bendersky added the comment: > > Okay, I see your points. I can certainly agree with going with the str > representation when no numeric code is specified. But, if a numeric code > is specified (x, b, d, etc.) then the numeric value should be used. > > Agreed? > Yes. I suggest to wait a d

[issue18682] [PATCH] remove bogus codepath from pprint._safe_repr

2013-08-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Here is a patch which adds fast path for builtin scalar types. Or we can just remove a special case for strings. -- Added file: http://bugs.python.org/file31292/pprint_safe_repr_scalars.patch ___ Python tracker

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Ethan Furman
Ethan Furman added the comment: On 08/14/2013 11:55 AM, Eli Bendersky wrote: > > I'm not sure I understand. The discrepancy between {:} and {:10} is clearly > a problem. Ah, you're right. -- ___ Python tracker ___

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Ethan Furman
Ethan Furman added the comment: Okay, I see your points. I can certainly agree with going with the str representation when no numeric code is specified. But, if a numeric code is specified (x, b, d, etc.) then the numeric value should be used. Agreed? -- ___

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eric V. Smith
Eric V. Smith added the comment: I think IntEnum should act like a str for format() purposes. After all, having a useful string representation is a prime reason it exists. If you want it to act like a str() sometimes, and an int() at others, you're going to have to parse the format specifier a

[issue13504] Meta-issue for "Invent with Python" IDLE feedback

2013-08-14 Thread Kurt B. Kaiser
Changes by Kurt B. Kaiser : -- nosy: +kbk ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.or

[issue18740] str is number methods don't recognize '.'

2013-08-14 Thread Brett Cannon
Brett Cannon added the comment: Feel free to submit an issue suggesting better docstrings as that sounds like it could stand to get some TLC. -- ___ Python tracker ___ _

[issue18740] str is number methods don't recognize '.'

2013-08-14 Thread Ron Adam
Ron Adam added the comment: I get the same resluts if I make the string by str(123.0). I was thinking it should test True for the isdecimal case for that. It seems I missunderstood their purpose/use. This seems like it would be a very common misunderstanding. It appears, (Because it isn't s

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eli Bendersky
Eli Bendersky added the comment: On Wed, Aug 14, 2013 at 12:07 PM, Ethan Furman wrote: > > Ethan Furman added the comment: > > > Eric V. Smith added the comment: > > > > I assumed we'd want it to look like the str() version of itself, always. > But it's debatable. > > An IntEnum's str and repr s

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Ethan Furman
Ethan Furman added the comment: > Eric V. Smith added the comment: > > I assumed we'd want it to look like the str() version of itself, always. But > it's debatable. An IntEnum's str and repr should be (and any format or % codes that are the equivalent) the Enum str and repr. The % and forma

[issue18735] SSL/TLS pinning for the ssl module

2013-08-14 Thread Jesús Cea Avión
Jesús Cea Avión added the comment: This technique is used in Mercurial and I use it in my projects too. -- ___ Python tracker ___ ___

[issue18293] ssl.wrap_socket (cert_reqs=...), getpeercert, and unvalidated certificates

2013-08-14 Thread Jesús Cea Avión
Changes by Jesús Cea Avión : -- nosy: +jcea ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.

[issue18735] SSL/TLS pinning for the ssl module

2013-08-14 Thread Jesús Cea Avión
Changes by Jesús Cea Avión : -- nosy: +jcea ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eli Bendersky
Eli Bendersky added the comment: On Wed, Aug 14, 2013 at 11:56 AM, Eric V. Smith wrote: > > Eric V. Smith added the comment: > > For format, I think the question is "should an IntEnum format like an int, > with the wacky exception of a specifier of '', or should it always format > like a str?" >

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eric V. Smith
Eric V. Smith added the comment: For format, I think the question is "should an IntEnum format like an int, with the wacky exception of a specifier of '', or should it always format like a str?" I assumed we'd want it to look like the str() version of itself, always. But it's debatable. I ag

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eli Bendersky
Eli Bendersky added the comment: On Wed, Aug 14, 2013 at 11:48 AM, Ethan Furman wrote: > > Ethan Furman added the comment: > > > Eric V. Smith added the comment: > > > > For the format version, what gets called is: > > > > int_subclass.__format__('d'), which is int.__format__(int_subclass, > > '

[issue18740] str is number methods don't recognize '.'

2013-08-14 Thread Brett Cannon
Brett Cannon added the comment: Ned is right, everything is working as documented and intended: as a way to avoid using a regex to test a simple case instead of trying to do anything fancy like identify a number. -- nosy: +brett.cannon resolution: -> rejected status: open -> closed _

[issue18739] math.log of a long returns a different value of math.log of an int

2013-08-14 Thread Tim Peters
Tim Peters added the comment: OK, the correct one is issue #9959. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscr

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Ethan Furman
Ethan Furman added the comment: > Eric V. Smith added the comment: > > For the format version, what gets called is: > > int_subclass.__format__('d'), which is int.__format__(int_subclass, > 'd'), which produces '1', assuming int(int_subclass) is 1. Ah, I didn't realize. Thanks. > So, there's n

[issue18739] math.log of a long returns a different value of math.log of an int

2013-08-14 Thread Tim Peters
Tim Peters added the comment: FYI, the improvement was made in these 2 changesets: c8dc4b5e54fb a9349fd3d0f7 If desired, those could presumably be grafted back into the 2.7 branch. The commit messages refer to issue #9599, but that appears to be mistaken. -- _

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eric V. Smith
Eric V. Smith added the comment: >> >> I think that specifying __format__() would be best, except then you need to >> decide what sort of format specification language you want to support, and >> deal with all of the implementation details. Or, maybe just have Enum's >> __format__ be: >> >>

[issue18718] datetime documentation contradictory on leap second support

2013-08-14 Thread Roundup Robot
Roundup Robot added the comment: New changeset 5063dab96843 by David Wolever in branch '2.7': Issue #18718: datetime documentation contradictory on leap second support http://hg.python.org/cpython/rev/5063dab96843 -- nosy: +python-dev ___ Python track

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Ethan Furman
Ethan Furman added the comment: > Eric V. Smith added the comment: > > I think that specifying __format__() would be best, except then you need to > decide what sort of format specification language you want to support, and > deal with all of the implementation details. Or, maybe just have Enum

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eric V. Smith
Eric V. Smith added the comment: I think: >>> '{:}'.format(AF.IPv4) 'AF.IPv4' is correct, assuming str(AF.IPv4) is 'AF.IPv4'. I'm not sure what: >>> '{:10}'.format(AF.IPv4) should produce. There's a special case for an empty format string calling str(). I think that specifying __format__() w

[issue18740] str is number methods don't recognize '.'

2013-08-14 Thread Ned Deily
Ned Deily added the comment: isdecimal() is working as documented, isn't it? A period character serving as a decimal point is not the same as a decimal character. "Return true if all characters in the string are decimal characters and there is at least one character, false otherwise. Decimal

[issue18739] math.log of a long returns a different value of math.log of an int

2013-08-14 Thread Gregory P. Smith
Gregory P. Smith added the comment: We found this while refactoring an API to be more consistent about returning longs vs ints in specific cases. This resulted in another unittest that was using math.log for a nicer display of the value by magnitude to fail as the result was slightly differen

[issue18740] str is number methods don't recognize '.'

2013-08-14 Thread Ron Adam
New submission from Ron Adam: Shouldn't at least isdecimal return True? >>> '123.0'.isdecimal() False >>> '123.0'.isalnum() False >>> '123.0'.isnumeric() False >>> '123.0'.isdigit() False -- components: Interpreter Core messages: 195186 nosy: ron_adam priority: normal severity: normal s

[issue18739] math.log of a long returns a different value of math.log of an int

2013-08-14 Thread Tim Peters
Tim Peters added the comment: Yup - 2.7 evaluates this in a less precise way, as log(10L) = log(10./16 * 2**4) = log(0.625) + log(2)*4 >>> log(10L) == log(0.625) + log(2)*4 True This patterns works well even for longs that are far too large to represent as a double; e.g., >>> log(1L << 5

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Ethan Furman
Ethan Furman added the comment: Which is the same as '%s', yes? In that case, the current behavior of '{:}'.format(AF.IPv4) is correct, isn't it? -- ___ Python tracker ___

[issue18737] Get virtual subclasses of an ABC

2013-08-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: > I like to do something similar to marker interfaces [1] with ABCs. > For introspection and documentation I need a way to get all > non-abstract classes that are implemented by an ABC. You mean that implement an ABC? But you also need to return real subclasses

[issue18737] Get virtual subclasses of an ABC

2013-08-14 Thread Christian Heimes
Christian Heimes added the comment: I like to do something similar to marker interfaces [1] with ABCs. For introspection and documentation I need a way to get all non-abstract classes that are implemented by an ABC. How about I change the implementation to get_subclasses(direct=False) to retur

[issue8713] multiprocessing needs option to eschew fork() under Linux

2013-08-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: > I do see a couple of failed assertions on Windows which presumably > happen in a child process because they do not cause a failure: > > Assertion failed: !collecting, file ..\Modules\gcmodule.c, line > 1617 > > The assertion is in _PyGC_CollectNoFail(

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eric V. Smith
Eric V. Smith added the comment: > What is '{:}' supposed to mean? > It should be the same as '{}'. That is, an empty format string. -- ___ Python tracker ___ _

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Ethan Furman
Ethan Furman added the comment: The %-formatting needs to be handled by str, correct? What is '{:}' supposed to mean? -- ___ Python tracker ___ _

[issue18698] importlib.reload() does not return the module in sys.modules

2013-08-14 Thread Brett Cannon
Brett Cannon added the comment: I think you mean in 3.3 and yes. =) Patch LGTM so I say fix in 3.3 and merge into default. -- assignee: -> eric.snow ___ Python tracker ___

[issue8713] multiprocessing needs option to eschew fork() under Linux

2013-08-14 Thread Richard Oudkerk
Richard Oudkerk added the comment: > Good for me. This is a very nice addition! Thanks. I do see a couple of failed assertions on Windows which presumably happen in a child process because they do not cause a failure: Assertion failed: !collecting, file ..\Modules\gcmodule.c, line 1617

[issue18739] math.log of a long returns a different value of math.log of an int

2013-08-14 Thread Christian Heimes
Christian Heimes added the comment: Fascinating, how did you find the issue? -- nosy: +christian.heimes, mark.dickinson ___ Python tracker ___ ___

[issue18739] math.log of a long returns a different value of math.log of an int

2013-08-14 Thread Gregory P. Smith
New submission from Gregory P. Smith: This is a very odd inconsistency in math.log behavior. That said, it is probably only a single bit imprecision at the end of the float result. Still, 10 == 10L so I'd expect math.log of both to give the same result. oss/cpython/2.7:LOAS$ ./python Python

[issue8713] multiprocessing needs option to eschew fork() under Linux

2013-08-14 Thread Roundup Robot
Roundup Robot added the comment: New changeset 3b82e0d83bf9 by Richard Oudkerk in branch 'default': Issue #8713: Support alternative start methods in multiprocessing on Unix. http://hg.python.org/cpython/rev/3b82e0d83bf9 -- nosy: +python-dev ___ Pytho

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Ethan Furman
Ethan Furman added the comment: Gotcha. I'm on it. -- assignee: -> ethan.furman ___ Python tracker ___ ___ Python-bugs-list mailing

[issue18738] String formatting (% and str.format) issues with Enum

2013-08-14 Thread Eli Bendersky
Changes by Eli Bendersky : -- title: % formatting incomplete for Enum -> String formatting (% and str.format) issues with Enum ___ Python tracker ___ ___

[issue18738] % formatting incomplete for Enum

2013-08-14 Thread Eli Bendersky
Eli Bendersky added the comment: On Wed, Aug 14, 2013 at 6:55 AM, Serhiy Storchaka wrote: > > Serhiy Storchaka added the comment: > > `.format()` is surprised too. > > >>> '{:}'.format(AF.IPv4) > 'AF.IPv4' > >>> '{:10}'.format(AF.IPv4) > ' 1' > > Oh, this looks like a bug in str.format (

[issue18738] % formatting incomplete for Enum

2013-08-14 Thread Eli Bendersky
Eli Bendersky added the comment: Ethan, str.format uses __format__. We don't seem to provide a custom one. -- ___ Python tracker ___ _

[issue18738] % formatting incomplete for Enum

2013-08-14 Thread Ethan Furman
Ethan Furman added the comment: Looks like Objects/unicodeobject.c needs the same enhancement that Modules/_json.c received: convert int/float subclasses into actual ints/floats before continuing. -- ___ Python tracker

[issue18738] % formatting incomplete for Enum

2013-08-14 Thread Ethan Furman
Ethan Furman added the comment: '{:}'.format(AF.IPv4) is incorrect, but '{:10}'.format(AF.IPv4) behaves as it should. -- ___ Python tracker ___ _

[issue18720] Switch suitable constants in the socket module to IntEnum

2013-08-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Nitpick: If we have grouped this constants in an enum class perhaps it will be good if they will be enumerated in the order of its values. Or no? -- ___ Python tracker _

[issue18720] Switch suitable constants in the socket module to IntEnum

2013-08-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I thing the AddressFamily enum class and the family property should be documented. -- ___ Python tracker ___

[issue18606] Add statistics module to standard library

2013-08-14 Thread Ethan Furman
Changes by Ethan Furman : -- nosy: +ethan.furman ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.py

[issue18720] Switch suitable constants in the socket module to IntEnum

2013-08-14 Thread Eli Bendersky
Eli Bendersky added the comment: > I thing the AddressFamily enum class and the family property should be > documented. > I'm leaving the documentation to the end when we decide on the implementation strategy. Once that happens I'll post a patch with .rst changes, etc. -- _

[issue18720] Switch suitable constants in the socket module to IntEnum

2013-08-14 Thread Eli Bendersky
Eli Bendersky added the comment: Christian, this is an interesting idea - but I suggest we review it once we actually get to convert "many modules". For the time being the manual listing is gone in the recent patch, and for a number of constant families in the same module (i.e. SOCK_* that wil

[issue18738] % formatting incomplete for Enum

2013-08-14 Thread Eli Bendersky
Eli Bendersky added the comment: In Objects/unicodeobject.c when it gets into mainformatlong, an IntEnum is recognized as an integer (passes PyLong_Check) and goes into formatlong. There, in the cases of 'd', 'i', 'u' it has: case 'u': /* Special-case boolean: we want 0/1 */

[issue18738] % formatting incomplete for Enum

2013-08-14 Thread Eric V. Smith
Changes by Eric V. Smith : -- nosy: +eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyt

[issue18720] Switch suitable constants in the socket module to IntEnum

2013-08-14 Thread Christian Heimes
Christian Heimes added the comment: The manual list of AF_ prefixes looks ugly. We are going to run into the same problem for every module. How about an additional constructor that takes a name, dict and string prefix? class IntEnum(int, Enum): @classmethod def from_moduledict(cls, nam

[issue18738] % formatting incomplete for Enum

2013-08-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: `.format()` is surprised too. >>> '{:}'.format(AF.IPv4) 'AF.IPv4' >>> '{:10}'.format(AF.IPv4) ' 1' -- ___ Python tracker ___

[issue18738] % formatting incomplete for Enum

2013-08-14 Thread Ethan Furman
New submission from Ethan Furman: While `.format()` works fine with enum, %-formatting does not: --> class AF(enum.IntEnum): ... IPv4 = 1 ... IPv6 = 2 ... --> AF.IPv4 --> '%s' % AF.IPv4 'AF.IPv4' --> '%r' % AF.IPv4 '' --> '%d' % AF.IPv4 'AF.IPv4' --> '%i' % AF.IPv4 'AF.IPv4' --> '%x'

[issue18720] Switch suitable constants in the socket module to IntEnum

2013-08-14 Thread Ethan Furman
Ethan Furman added the comment: Issue18738 created. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://m

[issue18682] [PATCH] remove bogus codepath from pprint._safe_repr

2013-08-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: We can just remove "if typ is str:" case at all. A general case works for strings. But for performance (this will slowdown Antoine's tests by 15-20%) we should left it and may be even extend it to other builtin types: builtin_type = (str, int, float, NoneTy

[issue18737] Get virtual subclasses of an ABC

2013-08-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: > It's called get_VIRTUAL_subclasses() for a reason. You can get the > real subclasses of an ABC with standard tool, e.g. recurse into > __subclasses__(). What use case are you trying to solve? If I want to find out all classes which implement an ABC, I don't ca

[issue18720] Switch suitable constants in the socket module to IntEnum

2013-08-14 Thread Eli Bendersky
Eli Bendersky added the comment: On Wed, Aug 14, 2013 at 6:24 AM, Serhiy Storchaka wrote: > > Serhiy Storchaka added the comment: > > I'm surprised that test_repr is not failed. '%i' % > socket.AddressFamily.AF_INET returns 'AddressFamily.AF_INET' instead of '2' > as I expected. Is not this a bu

[issue18720] Switch suitable constants in the socket module to IntEnum

2013-08-14 Thread Eli Bendersky
Eli Bendersky added the comment: Attaching a new patch that uses Serhiy's suggestion to avoid the duplication, and uses Antoine's suggestion to keep socket.family working even if the family is an unknown numeric constant. Note that the latter is challenging to test - I need families the OS kno

[issue18737] Get virtual subclasses of an ABC

2013-08-14 Thread Christian Heimes
Christian Heimes added the comment: It's called get_VIRTUAL_subclasses() for a reason. You can get the real subclasses of an ABC with standard tool, e.g. recurse into __subclasses__(). For virtual subclasses you have to deal with the internals like _abc_registry. I could implement all four cas

[issue18682] [PATCH] remove bogus codepath from pprint._safe_repr

2013-08-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: Ran some benchmark numbers: $ ./python -m timeit -s "from pprint import saferepr; s='é\"x' * 1000" "saferepr(s)" -> before patch: 555 usec per loop -> after patch: 10.9 usec per loop $ ./python -m timeit -s "from pprint import saferepr; s='xxx' * 1000" "safer

[issue18720] Switch suitable constants in the socket module to IntEnum

2013-08-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I'm surprised that test_repr is not failed. '%i' % socket.AddressFamily.AF_INET returns 'AddressFamily.AF_INET' instead of '2' as I expected. Is not this a bug in IntEnum implementation? -- ___ Python tracker

[issue18737] Get virtual subclasses of an ABC

2013-08-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: Another problem is what happens when an implementation uses non-"virtual" inheritance: >>> issubclass(collections.UserDict, collections.abc.Mapping) True >>> collections.UserDict in collections.abc.Mapping.get_virtual_subclasses(True) False IOW, I think this g

[issue18737] Get virtual subclasses of an ABC

2013-08-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: I'm not sure "recurse" is a relevant distinction here. A subclass of a subclass is still a subclass. "Virtual" subclasses should not be different. At the very least, if "recurse" is kept, I would expect it to be True by default. -- nosy: +pitrou

[issue18737] Get virtual subclasses of an ABC

2013-08-14 Thread Christian Heimes
New submission from Christian Heimes: ABCs are missing one important introspection feature. They have no API to get registered virtual subclasses. The patch implements a new method get_virtual_subclasses(recurse=False). ABC.get_virtual_subclasses() returns the direct virtual subclasses of an A

[issue18720] Switch suitable constants in the socket module to IntEnum

2013-08-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Can you clarify which duplication you mean specifically? In the code > review > tool, Serhiy proposed that instead of listing all the constants > explicitly > in the Python code, we can just do: > > AddressFamily = IntEnum('AddressFamily', >{name:

[issue18606] Add statistics module to standard library

2013-08-14 Thread Mark Dickinson
Mark Dickinson added the comment: Steven: were you planning to start a discussion thread on python-dev for PEP 450? I see that there's some activity on python-list and on python-ideas, but I think most core devs would expect the main discussions to happen on the python-dev mailing list. (An

[issue16463] testConnectTimeout of test_timeout TCPTimeoutTestCasefailures fails intermittently

2013-08-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: We can do this in the setUpClass() method. Or we can wrap the resolve_address() method with the @functools.lru_cache() decorator. -- nosy: +serhiy.storchaka ___ Python tracker

[issue18720] Switch suitable constants in the socket module to IntEnum

2013-08-14 Thread Eli Bendersky
Eli Bendersky added the comment: > What about SOCK_STREAM, SOCK_DGRAM, and SOCK_RAW? > This is a proof of concept. As I mentioned in the original message starting this issue - the SOCK_* constants will get the same treatment as AF_* constants, once we decide what the right treatment is. ---

[issue18720] Switch suitable constants in the socket module to IntEnum

2013-08-14 Thread Eli Bendersky
Eli Bendersky added the comment: > I'm not really thrilled by the current implementation. The way it is done > leads to duplication among socket constants. Can you clarify which duplication you mean specifically? In the code review tool, Serhiy proposed that instead of listing all the constants

  1   2   >