[issue41515] typing.get_type_hints generates KeyError
New submission from Eric Fahlgren : Windows 10 Pro 64 Python 3.8.3 64 wxPython 4.1.0 It appears that there are synthetic classes in the mro, which don't appear in the type's namespace, raising KeyError when encountered. From reading the function's doc and source, it looks like it should handle this internally and return a valid dict (possibly empty), and not raise KeyError. >>> import typing, wx >>> typing.get_type_hints(wx.Window)' Traceback (most recent call last): File "", line 1, in File "C:\Program Files\Python38\lib\typing.py", line 1223, in get_type_hints base_globals = sys.modules[base.__module__].__dict__ >>> wx.Window.mro() [, , , , , , , ] KeyError: 'sip' -- components: Library (Lib) messages: 375111 nosy: eric.fahlgren priority: normal severity: normal status: open title: typing.get_type_hints generates KeyError versions: Python 3.8 ___ Python tracker <https://bugs.python.org/issue41515> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39629] inspect.signature fails on math.hypot
New submission from Eric Fahlgren : Python 3.8's new math.hypot function also appears to suffer from the same issue as math.log: >>> import math, inspect >>> inspect.signature(math.hypot) Traceback (most recent call last): File "", line 1, in File "C:\Program Files\Python38\lib\inspect.py", line 3093, in signature return Signature.from_callable(obj, follow_wrapped=follow_wrapped) File "C:\Program Files\Python38\lib\inspect.py", line 2842, in from_callable return _signature_from_callable(obj, sigcls=cls, File "C:\Program Files\Python38\lib\inspect.py", line 2296, in _signature_from_callable return _signature_from_builtin(sigcls, obj, File "C:\Program Files\Python38\lib\inspect.py", line 2107, in _signature_from_builtin raise ValueError("no signature found for builtin {!r}".format(func)) ValueError: no signature found for builtin Possibly related to issue29299? -- components: Library (Lib) messages: 361966 nosy: eric.fahlgren priority: normal severity: normal status: open title: inspect.signature fails on math.hypot type: behavior versions: Python 3.8 ___ Python tracker <https://bugs.python.org/issue39629> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35785] argparse crashes in gettext when processing missing arguments
Eric Fahlgren added the comment: Thanks, I installed 3.7.2 on one of our non-production machines and it appears that gettext has been fixed, so I'm closing this. > python -V Python 3.7.2 > python bpo35785.py --foo usage: bpo35785.py [-h] [--foo FOO] bpo35785.py: error: argument --foo: expected one argument -- resolution: -> fixed stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue35785> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35785] argparse crashes in gettext when processing missing arguments
Eric Fahlgren added the comment: After a bit more digging, it's a side effect of having the locale set with 'Plural-Forms'. I've attached the resulting .mo file, but since it's a binary, I'm not sure it will work cross-platform, so here's how to recreate it. > cat en_US/LC_MESSAGES/foo.po msgid "" msgstr "Plural-Forms: nplurals=2; plural=(n != 1);\n" > python /Python37/Tools/i18n/msgfmt.py en_US/LC_MESSAGES/foo.po > ll en_US/LC_MESSAGES/ -rwx--+ 1 efahlgren Domain Users 89 2019-01-19 14:36 foo.mo* -rw-r--r--+ 1 efahlgren Domain Users 69 2019-01-19 14:34 foo.po Then you can reproduce with some setup in your script: import os import gettext import argparse os.putenv('LANG', 'en_US') # Just to make sure. gettext.bindtextdomain('foo', '.') gettext.textdomain('foo') p = argparse.ArgumentParser() p.add_argument('--foo', nargs=None) p.parse_args() -- Added file: https://bugs.python.org/file48068/foo.mo ___ Python tracker <https://bugs.python.org/issue35785> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35785] argparse crashes in gettext when processing missing arguments
New submission from Eric Fahlgren : When argparse is configured with an option that takes arguments, then the script is invoked with the switch but no arguments, a nonsensical exception is raised during gettext processing. In the 3.7.1 source, the error is at line 2077 of argparse.py, where 'action.nargs' is not an integer as expected by 'ngettext', but one of None, '*' or '?': default = ngettext('expected %s argument', 'expected %s arguments', action.nargs) % action.nargs msg = nargs_errors.get(action.nargs, default) Fix should be pretty trivial, swap the two lines and if 'get' produces None, only then compute the default. File "C:\Program Files\Python37\lib\argparse.py", line 1749, in parse_args args, argv = self.parse_known_args(args, namespace) File "C:\Program Files\Python37\lib\argparse.py", line 1781, in parse_known_args namespace, args = self._parse_known_args(args, namespace) File "C:\Program Files\Python37\lib\argparse.py", line 1987, in _parse_known_args start_index = consume_optional(start_index) File "C:\Program Files\Python37\lib\argparse.py", line 1917, in consume_optional arg_count = match_argument(action, selected_patterns) File "C:\Program Files\Python37\lib\argparse.py", line 2079, in _match_argument action.nargs) % action.nargs File "C:\Program Files\Python37\lib\gettext.py", line 631, in ngettext return dngettext(_current_domain, msgid1, msgid2, n) File "C:\Program Files\Python37\lib\gettext.py", line 610, in dngettext return t.ngettext(msgid1, msgid2, n) File "C:\Program Files\Python37\lib\gettext.py", line 462, in ngettext tmsg = self._catalog[(msgid1, self.plural(n))] File "", line 4, in func File "C:\Program Files\Python37\lib\gettext.py", line 168, in _as_int (n.__class__.__name__,)) from None TypeError: Plural value must be an integer, got NoneType -- components: Library (Lib) messages: 334065 nosy: eric.fahlgren priority: normal severity: normal status: open title: argparse crashes in gettext when processing missing arguments versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue35785> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35785] argparse crashes in gettext when processing missing arguments
Change by Eric Fahlgren : -- type: -> crash ___ Python tracker <https://bugs.python.org/issue35785> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34252] Bunch of path leaks on Python 3.7 on Release
Eric Fahlgren added the comment: I believe that the CL command line switch is /FC, not /FP: https://msdn.microsoft.com/en-us/library/027c4t2s.aspx -- nosy: +eric.fahlgren ___ Python tracker <https://bugs.python.org/issue34252> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33656] IDLE: Turn on DPI awareness on Windows
Eric Fahlgren added the comment: So maybe add the dpiAware and dpiAwareness settings to the manifest for just Windows' pythonw.exe and leave the python.exe console interpreter alone? I'm going to guess that the pythonw.exe manifest already has some settings related to its unique status that align with this. -- ___ Python tracker <https://bugs.python.org/issue33656> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33656] IDLE: Turn on DPI awareness on Windows
Eric Fahlgren added the comment: https://msdn.microsoft.com/en-us/library/windows/desktop/mt748620(v=vs.85).aspx gives the syntax for adding dpiAwareness to the Windows manifest. -- nosy: +eric.fahlgren ___ Python tracker <https://bugs.python.org/issue33656> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26698] Tk DPI awareness
Eric Fahlgren added the comment: I used the default Application setting. -- ___ Python tracker <https://bugs.python.org/issue26698> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26698] Tk DPI awareness
Eric Fahlgren added the comment: Still blurry with 3.6.5 on Win 10 with a 2560x1600 monitor at 125% scaling (I compared it to 2.7.15, they looked identical). If I go to the Windows properties for pythonw.exe and turn on "Override high DPI scaling behavior" it's nice and sharp. -- nosy: +eric.fahlgren ___ Python tracker <https://bugs.python.org/issue26698> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1495754] os.listdir(): inconsistent behavior with trailing spaces
Eric Fahlgren added the comment: Would it be appropriate to make a comment about this Windows bug in both os.stat and os.path.exists documentation? I just stumbled upon it independently (both Win7 and 10, both Py 2.7 and 3.6) with nearly the same incantation that Kenneth reported over 10 years ago (exists check success, followed by scandir failure). [My workaround was to append os.sep to the directory spec: os.path.exists(newdir+os.sep) -> False ] Clearly this behavior is not going away, so it should at least be mentioned somewhere more prominently than on a decade old BPO item... -- nosy: +eric.fahlgren ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue1495754> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29282] Fused multiply-add: proposal to add math.fma()
Changes by Eric Fahlgren <ericfahlg...@gmail.com>: -- nosy: +eric.fahlgren ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29282> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23407] os.walk always follows Windows junctions
Eric Fahlgren added the comment: > # Junctions are not recognized as links. > self.assertFalse(os.path.islink(self.junction)) If the above comment is intended as a statement of fact, then it's inconsistent with the implementation of Py_DeleteFileW ( https://hg.python.org/cpython/file/v3.6.0/Modules/posixmodule.c#l4178 ). -- nosy: +eric.fahlgren ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23407> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26448] dis.findlabels ignores EXTENDED_ARG
Eric Fahlgren added the comment: Thanks, Serhiy. I sort of figured that it would get fixed with the wordcode rework, and was going to verify that it was when 3.6 settled down. On Sun, Jun 5, 2016 at 8:30 AM, Serhiy Storchaka <rep...@bugs.python.org> wrote: > > Serhiy Storchaka added the comment: > > This bug was fixed in issue26881 with similar patch. Sorry, I didn't know > about this issue. Your patches look good. In any case thank you for your > effort. > > -- > nosy: +serhiy.storchaka > resolution: -> out of date > stage: -> resolved > status: open -> closed > superseder: -> modulefinder should reuse the dis module > > ___ > Python tracker <rep...@bugs.python.org> > <http://bugs.python.org/issue26448> > ___ > -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26448> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27129] Wordcode, part 2
Changes by Eric Fahlgren <ericfahlg...@gmail.com>: -- nosy: +eric.fahlgren ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27129> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22893] Idle: __future__ does not work in startup code.
Changes by Eric Fahlgren <ericfahlg...@gmail.com>: -- nosy: +eric.fahlgren ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22893> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26448] dis.findlabels ignores EXTENDED_ARG
Eric Fahlgren added the comment: Barun, take a look at the latest version of the testfindlabels.py, see what you think. If it works for you, maybe move the test function into Lib/test/test_dis.py as part of the standard dis module tests. Still need to look at the code that's being tested and find out what cases could cause problems and then augment the test to make sure it covers those. -- Added file: http://bugs.python.org/file42065/dis_with_code_scanner.diff ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26448> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26448] dis.findlabels ignores EXTENDED_ARG
Eric Fahlgren added the comment: Oops, wrong/bad patch, delete line 310 "arg = None" in _get_instruction_bytes... -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26448> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26448] dis.findlabels ignores EXTENDED_ARG
Eric Fahlgren added the comment: Two things: 1) Verified this has always been a problem and still is in the development branch, so I added 2.7 and 3.6 to the versions list. 2) Couldn't tolerate the duplicate code handling the extended args operator, so in the interests of DRY, I moved the code scanner to a generator function (see attached dis_with_code_scanner.diff). The patch is definitely not required to fix this bug, but it does isolate the original problem area to just one piece of code. Could we get a get a quick review from a core dev saying either "go with Barun's less invasive preliminarypatch.diff" or "go with Eric's greater-churn dis_with_code_scanner.diff patch?" (We still need to flesh out the testing a bit, so don't call us, we'll call you. :) ) -- versions: +Python 2.7, Python 3.6 Added file: http://bugs.python.org/file42047/dis_with_code_scanner.diff ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26448> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26448] dis.findlabels ignores EXTENDED_ARG
Eric Fahlgren added the comment: I just remembered that code can have more than one (up to three?) EXTENDED_ARG operators before the real opcode, so I added that generalization to build code around the args list... -- Added file: http://bugs.python.org/file42046/testfindlabels.py ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26448> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26448] dis.findlabels ignores EXTENDED_ARG
Eric Fahlgren added the comment: Oh, don't worry about time between responses, we all have lives (well, some of us anyhow :) ). After looking at Lib/test/test_dis.py, I think it's just an oversight that there is no specific findlabels test (it's tested implicitly by ``dis.dis`` after all), and it would be good thing for you to add one. The obvious place seems like a new method at the bottom of the ``DisTests`` class, but we'll have to rely on (probably) Yury to make that call. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26448> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26448] dis.findlabels ignores EXTENDED_ARG
Eric Fahlgren added the comment: Lookin' good so far. How about we try it on all the opcodes that have arguments? See attached example for which I can see two obvious improvements: 1) It could be improved by taking apart that "args" list and using it to synthesize "sample_code" rather than having to hand duplicate the values in two places, albeit with different byte order. 2) Likewise, my hard-coded "offsets" table is pretty awful. :) Also, is there already a test for the dis module in which you could just add this as a case? -- Added file: http://bugs.python.org/file42039/testfindlabels.py ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26448> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26448] dis.findlabels ignores EXTENDED_ARG
Eric Fahlgren added the comment: The findlabels function takes a bytecode array of type bytes, usually the actual code from a function. My original test case uses the full Python compiler from source code to a CodeType object to create the bytecodes (plus all that other stuff that makes up a function), then extracts just the interesting part and passes that into findlabels. The good part is that you can pretend you're the compiler by just putting the correct bytes into a array and feed it into the various dis functions. The EXTENDED_ARG operator plays with the operand of the succeeding instruction, everything else either doesn't have an argument or has two bytes. Here's a real test case, I don't know how you write unit tests for the stdlib, but you can compare the output of the findlabels call with a known value, and that should get you pretty close. from opcode import * code = bytes( chr(opmap["JUMP_FORWARD"]) + chr(0) + chr(0) + chr(EXTENDED_ARG) + chr(1) + chr(0) + chr(opmap["JUMP_FORWARD"]) + chr(0) + chr(0) + chr(opmap["RETURN_VALUE"]), encoding="latin-1" ) import dis dis.dis(code) print(dis.findlabels(code)) if dis.findlabels(code) == [0x+3, 0x0001+9]: print("Test passed") Take a look in the stdlib opcode.py and find the various "JUMP" operators, those are the guys we care about for this. Try out a bunch of cases by augmenting the above definition of "code" and you'll soon get a feel for what's going on. As real, executable bytecode the above is of course non-sensical, but for a test, it's great because you can predict exactly what should be produced. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26448> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26448] dis.findlabels ignores EXTENDED_ARG
Eric Fahlgren added the comment: Well, now that I'm thinking about it, you could synthesize a bytecode stream trivially and have a much better test. This is completely off the top of my head, so take it is guaranteed to (probably) not work as written, but it should get you started: from opcodes import * import dis bytecode = ( chr(EXTENDED_ARG) + chr(1) + chr(0) + chr(JUMP_IF_TRUE_OR_POP) + chr(0) + chr(0) ) print(dis.findlabels(bytecode)) -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26448> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26448] dis.findlabels ignores EXTENDED_ARG
Eric Fahlgren added the comment: Our paths crossed, I don't know exactly how you'd add a test case for this, maybe construct the monster function in a string, eval the string, the use the synthesized function in dis.findlabels? -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26448> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26448] dis.findlabels ignores EXTENDED_ARG
Eric Fahlgren added the comment: My test case: def long(): z = a = b = c = d = e = f = g = h = 1 while x: x = x if x and x or not x else x above line repeated 2999 more times import dis print(dis.findlabels(long.__code__.co_code)[:10]) Buggy output: [35510, 35509, 62, 69, 78, 81, 93, 100, 109, 112] Correct output: [101046, 101045, 62, 69, 78, 81, 93, 100, 109, 112] -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26448> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26448] dis.findlabels ignores EXTENDED_ARG
New submission from Eric Fahlgren: When trying out dis.dis on some synthetically long functions, I noted that spurious branch targets were being generated in the output. First one is at address 8: 157 0 LOAD_CONST 1 (1) 3 DUP_TOP 4 STORE_FAST 0 (z) 7 DUP_TOP >>8 STORE_FAST 1 (a) 11 DUP_TOP I dug into findlabels and notices that it pays no attention to EXTENDED_ARG. The fix is pretty simple, basically copy pasta from dis._get_instructions_bytes, at line 369, in the 3.5.1 release code add all the "extended_arg" bits: extended_arg = 0 while i < n: op = code[i] i = i+1 if op >= HAVE_ARGUMENT: arg = code[i] + code[i+1]*256 + extended_arg extended_arg = 0 i = i+2 if op == EXTENDED_ARG: extended_arg = arg*65536 label = -1 -- components: Library (Lib) messages: 260913 nosy: eric.fahlgren priority: normal severity: normal status: open title: dis.findlabels ignores EXTENDED_ARG type: behavior versions: Python 3.5 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26448> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26110] Speedup method calls 1.2x
Changes by Eric Fahlgren <ericfahlg...@gmail.com>: -- nosy: +eric.fahlgren ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26110> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26252] Add an example to importlib docs on setting up an importer
Changes by Eric Fahlgren <ericfahlg...@gmail.com>: -- nosy: +eric.fahlgren ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26252> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com