[issue26287] Core dump in f-string with formatting errors due to refcount bug
Eric V. Smith added the comment: Yes, that's my thinking as well. I'll have a patch soon-ish. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26287> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26287] Core dump in f-string with formatting errors
Eric V. Smith added the comment: Now I think it's not a refcount problem. I'm going to switch to POP/PUSH instead of TOP/SET_TOP. I believe the problem is that I'm not adjusting the top of stack if there's an error. -- title: Core dump in f-string with formatting errors due to refcount bug -> Core dump in f-string with formatting errors ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26287> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26287] Core dump in f-string with formatting errors
Eric V. Smith added the comment: Thanks for the report and the debugging help. -- resolution: -> fixed stage: -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26287> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26287] Core dump in f-string with lambda and format specification
Changes by Eric V. Smith <e...@trueblade.com>: -- assignee: -> eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26287> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26344] `sys.meta_path` Skipped for Packages with Non-Standard Suffixed `__init__` Files
Changes by Eric V. Smith <e...@trueblade.com>: -- nosy: +brett.cannon, eric.smith, eric.snow, ncoghlan ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26344> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26229] Make number serialization ES6/V8 compatible
Eric V. Smith added the comment: Do you have a pointer to the spec which requires -0 vs. -3.333e+20, for example? -- nosy: +eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26229> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26276] Inconsistent behaviour of PEP 3101 formatting between versions
Changes by Eric V. Smith <e...@trueblade.com>: -- nosy: +eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26276> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26276] Inconsistent behaviour of PEP 3101 formatting between versions
Eric V. Smith added the comment: Hi, Mark. Yes, PEP 3101 is very much under-specified in this area. I tried to avoid the same mistake in PEP 498, although of course that's a different problem area. I don't recall why this particular case broke between 3.2.3 and 3.4.3. I'll try and track it down. I'm sure we were trying to "fix" some other edge condition. FWIW, in 3.4.3 this also fails, as expected: >>> "{ {{ 0} }}".format_map({' {{ 0} }': 'X'}) Can you try it in 3.2.3? I expect it to work, but you never know. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26276> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26241] repr() and str() are identical for floats in 3.5
Changes by Eric V. Smith <e...@trueblade.com>: -- nosy: +eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26241> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26223] decimal.to_eng_string() does not implement engineering notation in all cases.
Eric V. Smith added the comment: Agreed. And, since any API change would just be a 3.6+ change, this would increase the difficulty of moving between 2.7 and 3.x. Which is not something we want. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26223> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26429] os.path.dirname returns empty string instead of "." when file is in current directory
Eric V. Smith added the comment: Changing to just 3.6, since that's the only place we could change the behavior. That said, I'd be -1 on making such a change. It would no doubt break some existing code. -- nosy: +eric.smith type: -> enhancement versions: -Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26429> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26422] printing 1e23 and up is incorrect
Eric V. Smith added the comment: Please see https://docs.python.org/3.5/tutorial/floatingpoint.html for a discussion of why this is not a bug. -- nosy: +eric.smith resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26422> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26196] Argparse breaks when a switch is given an argument beginning with a dash
Eric V. Smith added the comment: I believe this is a duplicate of issue 9334. There's a lot of discussion there. -- nosy: +eric.smith stage: -> resolved status: open -> closed superseder: -> argparse does not accept options taking arguments beginning with dash (regression from optparse) ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26196> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26506] hex() documentation: mention "%x" % int
Eric V. Smith added the comment: Without lots of analysis (and disassembly), I can't speak to how valid your tests are, but they don't seem unreasonable. format() will always be slower, because it's more general (primarily in that it can be extended to new types). Plus, it involves at least a name lookup that %-formatting can skip. The usual ways to optimize this lookup holds here, too, if speed is really that critical (which I'm skeptical of). For example, say you had a custom type which implemented __format__ to understand the "X" format code. Using format(), this type could format itself as hex. %-formatting can't do that. In any event, I don't think we want to promulgate the fastest way to do a hex conversion, just the clearest. I can't say why format() in 3.5 is slower. There are many changes and tracking it down would be quite time consuming. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26506> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15660] Clarify 0 prefix for width specifier in str.format doc,
Eric V. Smith added the comment: > ''' > When no explicit alignment is given, preceding the width field by a zero > ('0') character enables sign-aware zero-padding for numeric types. This is > equivalent to a fill character of '0' with an alignment type of '='. > ''' I think that's good. > I presume the problem with changing the error message is that it is not > immediately known that alignment was set implicitly, by 0 before decimal > width, rather than explicitly. If the spec string is still available, it > could be searched and the message adjusted if '=' is not present. That > proposal should be a new issue if someone wants to push it. Yes, that's the problem. I guess it would be easier to keep track of which fields were set via defaults, and which explicitly. Currently, that information is lost. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15660> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26713] Change f-literal grammar so that escaping isn’t possible or necessary
Eric V. Smith added the comment: I agree with David here, this isn't a bug tracker level issue. But, to the specifics of your example, it already works: Python 3.6.0a0 (default:9095a5787a82+, Feb 5 2016, 18:24:55) [GCC 5.2.1 20151010] on linux Type "help", "copyright", "credits" or "license" for more information. >>> f'spam{(lambda: 1)():<4}' 'spam1 ' >>> The section of the docs you cited is only talking about single quotes, double quotes, escaped quotes, triple quotes and the like. So I'm not clear what changes you'd be proposing. If you bring this up on python-ideas, please be specific about what you'd change. Thanks! -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26713> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26506] hex() documentation: mention "%x" % int
Eric V. Smith added the comment: For 3.5 and 2.7, I'd suggest: format(value, 'x') or: format(value, 'X') Although you might disagree because of the verbosity. But at least you're not parsing a string at runtime. And for 3.6 with PEP-498: f'{value:x}' There are of course options for padding and adding the '0x', as well. -- nosy: +eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26506> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26468] shutil.copy2 raises OSError if filesystem doesn't support chmod
Eric V. Smith added the comment: I agree that copy2 should not fail because chmod fails. Could you please provide the entire traceback message when it fails (on both 2.7 and 3.4 or 3.5)? And what OS are you running on, and what filesystem? It looks like the error happens because errno=95 (EOPNOTSUPP, probably) isn't in the list of errors that _copyxattr catches, while (ENOTSUP=134 on Linux) is. I think the documentation is also incorrect. Of course copy2 can fail: what about out of disk space? I think the documentation is trying to say that copy2 never fails because it can't preserve metadata. And the wording in the docs "copy2() never returns failure" is also odd, it should say "copy2() never raises an exception because it cannot preserve file metadata". -- assignee: -> docs@python components: +Documentation nosy: +docs@python, eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26468> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27070] Add ability to freeze (seal) mutable objects
Eric V. Smith added the comment: There's a link in the PEP to the discussion on why it was rejected. There's a lot to read in the thread (I just spent 30 minutes re-reading it!). I'm going to close this. If you'd like to re-open the discussion with new insights, I'd suggest posting to python-ideas. But, given the existing discussion referenced by the PEP, I don't have high hopes, unless you have a compelling use case (which is always possible, of course). -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27070> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27087] unable to use socket send and sendall due to type error
Eric V. Smith added the comment: You'll need to convert the string to bytes first, by using .encode(). -- nosy: +eric.smith resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27087> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27080] Implement the formatting part of PEP 515, '_' in numeric literals.
New submission from Eric V. Smith: I've separated this out from issue 26331, so as to not interfere with discussions and code reviews for the parsing portion of the PEP. -- assignee: eric.smith components: Interpreter Core messages: 266023 nosy: eric.smith priority: normal severity: normal status: open title: Implement the formatting part of PEP 515, '_' in numeric literals. type: enhancement ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27080> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26331] Tokenizer: allow underscores for grouping in numeric literals
Eric V. Smith added the comment: I've created issue 27080 to track the formatting part of this. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26331> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27078] Make f'' strings faster than .format: BUILD_STRING opcode?
Eric V. Smith added the comment: I considered doing this, and have some of it implemented. I discussed it with Larry Hastings and Mark Shannon at PyCon Ireland, and we decided to just use ''.format() and the new FORMAT_VALUE opcode, since that was the simplest way to fix the previous implementation's faults. That doesn't mean I've given up on improving it, of course. The speed increase would indeed come from avoiding the LOAD_ATTR lookup, not building list, and not calling a function. I'm curious about your benchmarks. Can you share them? I've found f-strings to be typically faster than .format(). But I can't say my benchmarks are particularly awesome. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27078> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27078] Make f'' strings faster than .format: BUILD_STRING opcode?
Changes by Eric V. Smith <e...@trueblade.com>: -- assignee: -> eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27078> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27080] Implement the formatting part of PEP 515, '_' in numeric literals.
Changes by Eric V. Smith <e...@trueblade.com>: -- nosy: +georg.brandl ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27080> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27070] Add ability to freeze (seal) mutable objects
Eric V. Smith added the comment: See the rejected PEP 351: https://www.python.org/dev/peps/pep-0351/ -- nosy: +eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27070> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26331] Tokenizer: allow underscores for grouping in numeric literals
Eric V. Smith added the comment: Yes, I'll read PEP 515 and work on the formatting. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26331> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18531] Undocumented different between METH_KEYWORDS and **kws
Eric V. Smith added the comment: Okay. Adding back 3.5 and 2.7, in case someone wants to document the behavior there. I'm not sure if we fix docs in 3.4 still. -- versions: +Python 2.7, Python 3.5 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18531> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18531] Undocumented different between METH_KEYWORDS and **kws
Eric V. Smith added the comment: I think it's okay to change this as far as str.format() goes. Interestingly enough, the motivating case to add str.format_map() in issue 6081 was exactly this kind of code. Although I notice that the example in that issue, which it shows as failing, works in both 2.7 and 3.4 (the only versions I have handy). So I'm not sure what changed after 2009 to cause that code to start working, but I'd be okay with it breaking again. But maybe we should track it down, in case it was deliberately changed and is important to someone. In any event, since str.format_map() is well-known (to me, at least!), and is the approved way of getting the behavior of passing a specific map in to the format machinery, I'm okay with changing **dict to create an exact new dict, at least as far as str.format() goes. I can't speak to the overall implications (such as other APIs and performance). I agree it would be a 3.6 only change (and I've change the versions to reflect that). -- versions: -Python 2.7, Python 3.5 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18531> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26906] format(object.__reduce__) fails intermittently
Changes by Eric V. Smith <e...@trueblade.com>: -- nosy: +eric.smith type: -> behavior ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26906> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26947] Documentation improvement needed
Eric V. Smith added the comment: I'm a native speaker, and it's not the greatest sentence. How about: All of Python’s immutable built-in objects (such as numbers, strings and tuples) are hashable. None of its mutable containers (such as lists or dictionaries) are hashable. -- nosy: +eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26947> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18531] Undocumented different between METH_KEYWORDS and **kws
Eric V. Smith added the comment: I'm not sure PyObject_GetItem instead of PyDict_GetItem in 3.x completely explains things, because the code in issue 6081 also works in 2.7. But I don't think it's terribly important in any event, as long as we understand the 3.x difference. Thanks for researching! -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18531> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26981] add compatibility shim for enum34 backport
Eric V. Smith added the comment: Doesn't namedtuple use _fields (as opposed to _fields_) for a similar purpose? Would Enum using _order be more consistent with that? -- nosy: +eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26981> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26785] repr of -nan value should contain the sign
Changes by Eric V. Smith <e...@trueblade.com>: -- nosy: +eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26785> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26785] repr of -nan value should contain the sign
Eric V. Smith added the comment: Changing versions. I left in 2.7, but I doubt we'd make any changes to 2.7 with regards to this. -- versions: -Python 3.2, Python 3.3 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26785> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18531] Undocumented different between METH_KEYWORDS and **kws
Eric V. Smith added the comment: Oops, sorry. I'm an idiot. I was running in a venv where python was python3. Checking with my installed 2.7.10, I see the expected error. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18531> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27078] Make f'' strings faster than .format: BUILD_STRING opcode?
Eric V. Smith added the comment: I intend to review this. As this is not a new feature, it doesn't need to be completed by beta 1. I'm focusing my energies on new features, then I'll look at this. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27078> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27708] Rounding/Large Int representation error with multiplication and division
Changes by Eric V. Smith <e...@trueblade.com>: -- title: Roudning/Large Int representation error with multiplication and division -> Rounding/Large Int representation error with multiplication and division ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27708> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27708] Roudning/Large Int representation error with multiplication and division
Eric V. Smith added the comment: Thanks for giving an example. You misunderstand how the "/" operator works in python 3.x: the result is always a float. If you use "//", you'll get an integer: >>> 346624232496199842417306589390203563969059156941566239998694701635250663711452284218031962223891107456 >>> // 8 4332802906202498030216332367377544549613239461769577836837704406332963931535527253995277986388432 -- status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27708> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27078] Make f'' strings faster than .format: BUILD_STRING opcode?
Eric V. Smith added the comment: > And the expected performance for optimal `f'X is {x}'` code would > be *faster* than `"'X is %s' % (x,)"` which still needs to > interpret the string at runtime, and build a proper tuple object > on stack. That's not necessarily true. The f-string version still needs to invoke the .format() method on the object, instead of only working for a handful of hard-coded types. I'm not saying there aren't optimization opportunities, but it may be that %-formatting is always faster. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27078> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27708] Roudning/Large Int representation error with multiplication and division
Eric V. Smith added the comment: Since your result is 6.754791118045615e+200, it's definitely not stored as an integer. If you would show us exactly how you calculated this value, we can explain where the conversion to floating point is taking place. In the meantime, I'm going to close this issue, since it's not an problem with python integers. -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27708> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27708] Roudning/Large Int representation error with multiplication and division
Eric V. Smith added the comment: Actually, Python represents large integers exactly. Can you provide a specific example of a problem you're seeing? -- components: +Interpreter Core -ctypes nosy: +eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27708> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29467] Allow return mismatch to be caught by function
Eric V. Smith added the comment: Thanks for the suggestion. However, I don't think it's possible or desirable for python to implement this. There are two problems: 1) the internals of python would have to be drastically changed to support this, and 2) you'd need different syntax to support this. For item 2, consider: def f(): try: return some_other_function() except: return 1,2 You can't distinguish between your proposed type mis-match exception and some_other_function() raising a TypeError. I suppose you could invent another exception type, but you'll always have a similar problem. A larger problem is that this behavior would be confusing to both newcomers and existing programmers, it adds nothing that can't currently be done, and it would be a source of subtle bugs. If you really want to explore this, I suggest working out a more complete example and bringing it up on the python-ideas mailing list. You'll want to include code that currently exists that would be made simpler with your proposal. If you can find any such code in the standard library, that would be a bonus. Thanks again. -- nosy: +eric.smith resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29467> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29446] Improve tkinter 'import *' situation
Eric V. Smith added the comment: Instead of: __all__ = [name for name in globals() if not name.startswith('_') and name not in {'enum', 're', 'sys', 'wantobjects'}] Maybe this would be less fragile: import types __all__ = [name for name, obj in globals().items() if not name.startswith('_') and not isinstance(obj, types.ModuleType) and name not in {'wantobjects'}] That is, exclude all modules. Admittedly, I had to import types, but there are other ways to do this test without that import. -- nosy: +eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29446> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28489] Fix comment in tokenizer.c
Eric V. Smith added the comment: Right, that's basically what _all_string_prefixes() does: it starts with the 6 unique prefixes that are case- and order- independent ('b', 'r', 'u', 'f', 'br', 'fr'), and adds the cased and ordered versions. If you're saying that we should list those 8, and say "with all combinations of case", then I think we'd better off listing the 6 and saying "with all combinations of case and order". That's mainly because if "fbr" gets added, then the list of ordered ones gets larger. But it's just a comment. I think we should just commit Ryan's last patch. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28489> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29380] A lot of warning while executing make install
Eric V. Smith added the comment: Can you give us your platform, platform version, compiler, and compiler version? Also, the entire output of "make install" (or whatever make command you're running). Thanks. -- nosy: +eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29380> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29391] Windows Defender finds trojan Spursint in Numpy for Py36 Win64
Eric V. Smith added the comment: You should report this to the Numpy tracker. It's a third party package. -- nosy: +eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29391> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29526] Documenting format() function
Eric V. Smith added the comment: Since these codes don't apply to all types, you'll need some words saying what they do apply to. For example, None being the same as "g" is true for int, float, and Decimal; but None is "s" for strings. And, for example, none of the listed codes apply to datetime's. I'm +0 on this if we can get the wording right. -- nosy: +eric.smith versions: -Python 3.3, Python 3.4 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29526> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27080] Implement the formatting part of PEP 515, '_' in numeric literals.
Eric V. Smith added the comment: Unfortunately I'm not going to have time to implement this before 3.6 beta 1, so I'm un-assigning it to myself. I'll post to python-dev and hopefully someone else can get to it. Apologies for waiting so long. -- assignee: eric.smith -> versions: +Python 3.6 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27080> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27921] f-strings: do not allow backslashes
New submission from Eric V. Smith: See https://mail.python.org/pipermail/python-dev/2016-August/145979.html for details. PEP 498 is going to be changed to disallow backslashes inside braces (the expression portions of an f-string). However, I can't get that change done in time for 3.6 beta 1. So, this bug will disallow any backslashes in f-strings. Before the next beta, I'll implement the correct behavior. This is a breaking change: f-strings like f'\\t{3}' which worked in 3.6 alphas will not work in 3.6 beta 1, but will work in beta 2. f-strings like f'{\'x\'}' which worked in 3.6 alphas, will not work in any beta or release version of 3.6. -- assignee: eric.smith components: Interpreter Core messages: 274079 nosy: eric.smith, ned.deily priority: release blocker severity: normal status: open title: f-strings: do not allow backslashes type: behavior versions: Python 3.6 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27921> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27921] f-strings: do not allow backslashes
Changes by Eric V. Smith <e...@trueblade.com>: -- keywords: +patch Added file: http://bugs.python.org/file44311/27921.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27921> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27921] f-strings: do not allow backslashes
Changes by Eric V. Smith <e...@trueblade.com>: -- stage: -> patch review ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27921> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27949] Fix description in bytes literal doc
Eric V. Smith added the comment: No problem! Thanks for caring enough to open an issue and submit a patch, even if we don't use it. -- stage: -> resolved ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27949> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27949] Fix description in bytes literal doc
Eric V. Smith added the comment: While they probably should be entered with escapes, there's no actual technical requirement for that. >From the command line, I can enter a control-A with control-V control-A (this >might be different depending on your environment, or if you use an editor). >This will enter a literal string containing a single character with value 1. That gives: >>> '^A' # ^A is the combination control-V control-A '\x01' >>> len('^A') 1 >>> ord('^A') 1 >>> b'^A' b'\x01' -- nosy: +eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27949> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27948] f-strings: allow backslashes only in the string parts, not in the expression parts
New submission from Eric V. Smith: See issue 27921. Currently (and for 3.6 beta 1), backslashes are not allowed anywhere in f-strings. This needs to be changed to allow them in the string parts, but not in the expression parts. Also, require that the start and end of an expression be literal '{' and '}, not escapes like '\0x7b' and '\u007d'. -- assignee: eric.smith components: Interpreter Core messages: 274294 nosy: eric.smith priority: normal severity: normal stage: needs patch status: open title: f-strings: allow backslashes only in the string parts, not in the expression parts type: behavior versions: Python 3.6 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27948> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27921] f-strings: do not allow backslashes
Eric V. Smith added the comment: See issue 27948 for adding backslashes back in to the string parts of an f-string. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27921> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27078] Make f'' strings faster than .format: BUILD_STRING opcode?
Eric V. Smith added the comment: Of course. Never mind. LGTM. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27078> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27078] Make f'' strings faster than .format: BUILD_STRING opcode?
Eric V. Smith added the comment: Left a review comment. I'd like to see this in before 3.6 beta 1. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27078> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27078] Make f'' strings faster than .format: BUILD_STRING opcode?
Eric V. Smith added the comment: Now that I've looked at PyUnicode_New, I agree with using PyUnicode_New(0, 0). I can't imagine we could measure the difference with optimizing it in the opcode itself before calling PyUnicode_New. Thanks for adding this, Serhiy. I think it's great stuff, and works well with FORMAT_VALUE. -- assignee: eric.smith -> serhiy.storchaka ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27078> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27921] f-strings: do not allow backslashes
Eric V. Smith added the comment: > This looks a little ugly. True. My goal is to get the simplest possible thing working now, and then before beta 2 fix it so that backslashes again work in the text portions of an f-string. After that, I'll fix this particular piece of code (and the others, plus the tests that can be made to work). Here's an updated patch. I'm planning on committing it today. -- Added file: http://bugs.python.org/file44347/27921-1.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27921> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27934] json float encoding incorrect for dbus.Double
Changes by Eric V. Smith <e...@trueblade.com>: -- nosy: +eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27934> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27948] f-strings: allow backslashes only in the string parts, not in the expression parts
Changes by Eric V. Smith <e...@trueblade.com>: -- stage: needs patch -> patch review ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27948> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27948] f-strings: allow backslashes only in the string parts, not in the expression parts
Eric V. Smith added the comment: This patch implements the new logic. It passes all of the fstring tests (except of course the ones that had backslashes in the expressions). I'd still like to add some more tests, because I'm not convinced the named unicode escapes are correct (f"\N{LEFT CURLY BRACE}". Because I'm now scanning the decoded utf-8 version of the string, I need to be aware of this syntax and not decide it's part of an expression (because of the braces). -- keywords: +patch Added file: http://bugs.python.org/file44438/27948-1.diff ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27948> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28002] Some f-strings do not round trip through Tools/parser/test_unparse.py
Changes by Eric V. Smith <e...@trueblade.com>: -- title: f-strings do not round trip through Tools/parser/test_unparse.py -> Some f-strings do not round trip through Tools/parser/test_unparse.py ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28002> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27921] f-strings: do not allow backslashes
Eric V. Smith added the comment: The problem with test_unparse is that: f'''{"'"}''' becomes: f'{"\'"}' when it's run through Tools/parser/unparse.py. I'll open another issue for this. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27921> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24454] Improve the usability of the match object named group API
Eric V. Smith added the comment: I added a note in Misc/NEWS. Is that not what you mean? I'll look at match_methods. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24454> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24454] Improve the usability of the match object named group API
Eric V. Smith added the comment: Fixed. Thanks, Serhiy. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24454> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24454] Improve the usability of the match object named group API
Eric V. Smith added the comment: On 9/11/2016 10:05 AM, Serhiy Storchaka wrote: > > Serhiy Storchaka added the comment: > > ./Modules/_sre.c:2425:14: warning: ‘match_getitem_doc’ defined but not used [- > Wunused-variable] Not in Visual Studio! Standby. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24454> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24454] Improve the usability of the match object named group API
Changes by Eric V. Smith <e...@trueblade.com>: -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24454> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28146] Confusing error messages in str.format()
Eric V. Smith added the comment: See also issue 27772. The difference in the error messages is due to the first ones looking for specific invalid combinations (in this case things the string formatter does not understand), and the last one which is "I have no idea what you're asking for". -- nosy: +eric.smith type: -> behavior ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28146> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27080] Implement the formatting part of PEP 515, '_' in numeric literals.
Eric V. Smith added the comment: Since Brett is working on the parsing part, I'll work on this. I might take a stab at the documentation first, but in any event I'll commit it tonight. -- assignee: -> eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27080> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27948] f-strings: allow backslashes only in the string parts, not in the expression parts
Eric V. Smith added the comment: Updated patch, works against HEAD. I added a few tests and tweaked some comments. My goal is to commit this today, before the 3.6b1 cutoff. I don't think there's much risk to it. I still need to update the PEP. -- Added file: http://bugs.python.org/file44499/27948-2.diff ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27948> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21879] str.format() gives poor diagnostic on placeholder mismatch
Changes by Eric V. Smith <e...@trueblade.com>: -- assignee: -> eric.smith versions: +Python 3.6 -Python 3.5 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21879> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27080] Implement the formatting part of PEP 515, '_' in numeric literals.
Eric V. Smith added the comment: I just noticed that the patch doesn't handle 'X' (uppercase) correctly, while it does handle 'x' (lowercase). I'll fix that when I commit. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27080> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27948] f-strings: allow backslashes only in the string parts, not in the expression parts
Eric V. Smith added the comment: I've fixed the code and fixed/added tests. I still need to update the docs and PEP 498. I'll create a separate issue for the docs, once I'm done with the PEP. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27948> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27080] Implement the formatting part of PEP 515, '_' in numeric literals.
Eric V. Smith added the comment: I also fixed the code so both '_' and ',' can't be specified, and added tests. The documentation is also updated. -- resolution: -> fixed stage: -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27080> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26331] PEP 515: Tokenizer: allow underscores for grouping in numeric literals
Eric V. Smith added the comment: I'm done with the formatting (issue 27080), so PEP 515 can be marked as final. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26331> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24454] Improve the usability of the match object named group API
Eric V. Smith added the comment: Updated patch, with docs. I'd like to get this in to 3.6. Can anyone take a look? -- Added file: http://bugs.python.org/file44522/issue-24454-1.diff ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24454> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28385] Bytes objects should reject all formatting codes with an error message
Eric V. Smith added the comment: Yes, I think we should implement this for object.__format__. Marking as easy. -- components: +Interpreter Core -Library (Lib) keywords: +easy (C) ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28385> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28128] Improve the warning message for invalid escape sequences
Eric V. Smith added the comment: Sorry for not responding earlier. It's unlikely I'll have time for this before beta 2, although I can probably get to it after that and before beta 3. Don't let me stop someone else from improving on the patch. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28128> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28385] Bytes objects should reject all formatting codes with an error message
Eric V. Smith added the comment: I left a comment on Rietveld, but repeating it here because for me those messages often go to spam: I think you want to make this more general, by modifying the message for the TypeError that follows. Any type that doesn't provide it's own __format__ should produce an error when using a non-empty format string. For example: >>> format({}, 'a') Traceback (most recent call last): File "", line 1, in TypeError: non-empty format string passed to object.__format__ Would be better as: TypeError: non-empty format string passed to __format__ for object of type "class <'dict'>" (Or some prettier way to print out the type). -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28385> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28128] Improve the warning message for invalid escape sequences
Eric V. Smith added the comment: Couldn't we create a private version of PyUnicode_DecodeUnicodeEscape, to be called by ast.c, which passes back invalid escape info? Then have the actual warning raised by ast.c, which knows enough about the context to generate a better error/warning. I think we'd only be able to report on he first error in a string, though, but I haven't thought it all the way through. I believe we'd only need to modify decode_unicode_with_escapes() in ast.c, which is called for both regular strings and f-string. And of course PyUnicode_DecodeUnicodeEscape would have to call the new private version and do the right thing. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28128> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28128] Improve the warning message for invalid escape sequences
Eric V. Smith added the comment: Here is an extremely rough patch that shows the basic concept. I named the private function _PyUnicode_DecodeUnicodeEscape. The problems with this patch are: 1. it always raises an error, not a warning 2. the private function isn't declared in a .h file 3. the name of the private function needs some thought 4. only the first invalid escape in a string is reported 5. I don't report the correct location in the string with the invalid escape 6. there may well be a memory leak 7. PEP 7 problems #1 is because I was too lazy to refactor ast_error() to format the string I need without raising an error. #5 could be solved with a callback and something to record multiple bad escapes per string, if we want to go that far. We'd have to decide how to show this. Multiple warnings, or one warning with multiple bad chars? The rest of it is just quality of implementation stuff that we can work out if the approach is sound. -- keywords: +patch Added file: http://bugs.python.org/file44694/28128.diff ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28128> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28128] Improve the warning message for invalid escape sequences
Eric V. Smith added the comment: Also, I assume this is a problem with all such syntax warnings: you only see this warning/error when the file is originally compiled. Once the .pyc file exists, you'll never see a warning or error. Maybe that's okay, but it means there's a certain class of installations (such as .pyc compiled at install time) that won't be able to know these warnings exist. This screwed me up for a while when I was developing this patch. The warnings disappeared! -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28128> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28128] Improve the warning message for invalid escape sequences
Eric V. Smith added the comment: I forgot: this is what Nick's example now looks like: $ ./python -Wall escape_warning.py Traceback (most recent call last): File "escape_warning.py", line 1, in import bad_escape File "/home/eric/local/python/cpython/bad_escape.py", line 1 print('\d') ^ SyntaxError: invalid escape sequence \d -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28128> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28128] Improve the warning message for invalid escape sequences
Eric V. Smith added the comment: Tim: Cool! That's way more useful than I thought it would be. Serhiy: It's a proof of concept. Lots of design remains to be done. I'm not sure we've agreed on the concept yet, so I don't think it's worthwhile designing the API. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28128> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28002] f-strings do not round trip through Tools/parser/test_unparse.py
New submission from Eric V. Smith: The problem relates to how f-strings are re-created. For the input file foo.txt containing this one line: f'''{"'"}''' Run: ./python Tools/parser/test_unparse.py foo.txt Gives this output: f'{"\'"}' This result is not a valid f-string, since it contains a backslash inside the expression part of the f-string. The input string is a valid f-string: >>> f'''{"'"}''' "'" -- components: Demos and Tools messages: 274841 nosy: eric.smith priority: low severity: normal status: open title: f-strings do not round trip through Tools/parser/test_unparse.py type: behavior versions: Python 3.6 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28002> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27921] f-strings: do not allow backslashes
Eric V. Smith added the comment: Issue 28002 tracks the problem with Tools/parser/unparse.py. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27921> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27833] Process is locked when try to execute Queue.put() inside
Eric V. Smith added the comment: Tim: I believe that's correct. I'm going to close this issue. Guni: If you have more information or you feel this is an actual bug, please post it here. -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue27833> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27833] Process is locked when try to execute Queue.put() inside
Eric V. Smith added the comment: Here's a slightly simplified version. I can reproduce this on Windows with 3.4.3 cygwin 32-bit and on Linux with 3.3.2 64-bit. -- nosy: +eric.smith Added file: http://bugs.python.org/file44211/27833.py ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27833> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28308] Accelerate 'string'.format(value, ...) by using formatted string literals
Eric V. Smith added the comment: One thing to be careful of here is that there's one slight difference between how str.format() and f-strings handle indexing of values. f-strings, of course, use normal Python semantics, but str.format() treats indexing by things that don't look like integers as string literals, not variables. It's an unfortunate left-over from the original PEP-3101 specification: >>> d = {'a':'string', 0:'integer'} >>> a = 0 >>> f'{d[0]}' 'integer' >>> '{d[0]}'.format(d=d) 'integer' >>> f'{d[a]}' 'integer' >>> '{d[a]}'.format(d=d) 'string' Note that the exact same expression {d[a]} is evaluated differently by the two ways to format. There's a test for this in test_fstring.py. Someday, I'd like to deprecate this syntax in str.format(). I don't think it could ever be added back in, because it requires either additional named parameters which aren't used as formatting parameters, or it requires global/local lookups (which isn't going to happen). i.e., this: '{d[a]}'.format(d=d, a=a) -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28308> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28307] Accelerate 'string' % (value, ...) by using formatted string literals
Eric V. Smith added the comment: There isn't a direct mapping between %-formatting and __format__ format specifiers. Off the top of my head, I can think of at least one difference: >>> '%i' % 3 '3' >>> '{:i}'.format(3) Traceback (most recent call last): File "", line 1, in ValueError: Unknown format code 'i' for object of type 'int' So you'll need to be careful with edge cases like this. Also, for all usages of %s, remember to call str() (or add !s): >>> '%s' % 1 '1' >>> f'{1:s}' Traceback (most recent call last): File "", line 1, in ValueError: Unknown format code 's' for object of type 'int' >>> f'{1!s:s}' '1' Although that also reminds me of this default alignment difference: >>> x=0 >>> '%2s' % x ' 0' >>> f'{x!s:2s}' '0 ' >>> f'{x!s:>2s}' ' 0' So, in general, the mapping will be difficult. On the other hand, if you can do it, and provide a function that maps between %-formatting codes and __format__ codes, then that might be a generally useful tool. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28307> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24549] string.format() should have a safe_substitute equivalent, to be run consecutively
Eric V. Smith added the comment: >> But that would require some discussion, to decide on the correct behaviour. >What open question(s) do you think of? You need to provide an exact specification of what you want. It's not clear, for example, if you want to support required positional placeholders ({0}, etc.) but optionally missing named placeholders ({foo}). I'd also suggest implementing this as a function, so you can get some real-world usage out of it. Maybe: def format_safe(s, *args, **kwargs): format_safe("{0} {1} {foo} {bar}", 'one', 'two', bar='bar') -> 'one two {foo} bar}' or whatever you decide the signature and functionality should be. You can probably subclass from string.Formatter to do some of the heavy lifting for you, so I expect this wouldn't be very hard, depending on what you're really after. While you might find this function useful, I don't want to get your hopes up that this would be added to core Python as a member of str. I still don't see why this would be better than a single call to .format() that specifies all of the parameters. You'd have to have some use case that doesn't involve chaining for that to make sense (to me). And maybe functools.partial() or some derivative would make sense in that case. -- status: open -> pending versions: +Python 3.7 -Python 3.6 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24549> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28633] Concatenating bytes literal and f-string causes segmentation fault
Changes by Eric V. Smith <e...@trueblade.com>: -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28633> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28633] Concatenating bytes literal and f-string causes segmentation fault
Eric V. Smith added the comment: Thanks, Serhiy. I updated the patch. -- Added file: http://bugs.python.org/file45385/28633-1.diff ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28633> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28633] Concatenating bytes literal and f-string causes segmentation fault
Changes by Eric V. Smith <e...@trueblade.com>: -- assignee: -> eric.smith ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28633> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28638] Creating namedtuple is too slow to be used in common stdlib (e.g. functools)
Eric V. Smith added the comment: This file is derived from my namedlist project on PyPI. I've stripped out the namedlist stuff, and just left namedtuple. I've also removed the Python 2 support, and I've removed support for default parameters. After that surgery, I have not tested it very well. Those are my excuses for why the code is more complex that it would be if I were writing it from scratch. Anyway, instead of using eval() of a string to create the new() function, I use ast manipulations to generate a function that does all of the correct type checking. It calls eval() too, of course, but with a code object. I originally wrote this as an exercise in learning how to generate AST's. I can't say it's the best way to solve this problem, and I haven't benchmarked it ever. So just consider it as a proof of concept, or ignore it if you're not interested. -- nosy: +eric.smith Added file: http://bugs.python.org/file45399/namedtuple1.py ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28638> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28590] fstring's '{' from escape sequences does not start an expression
Eric V. Smith added the comment: Thanks, Jason. I updated the PEP, so now I think the docs and PEP match the implementation. -- resolution: -> fixed stage: -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28590> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28633] Concatenating bytes literal and f-string causes segmentation fault
Eric V. Smith added the comment: Works: >>> f'' b'' File "", line 1 SyntaxError: cannot mix bytes and nonbytes literals Fails: >>> b'' f'' Segmentation fault $ Regular strings work: >>> '' b'' File "", line 1 SyntaxError: cannot mix bytes and nonbytes literals >>> b'' '' File "", line 1 SyntaxError: cannot mix bytes and nonbytes literals >>> -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28633> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28633] Concatenating bytes literal and f-string causes segmentation fault
Eric V. Smith added the comment: The ones in msg280228 give correct error messages. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28633> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com