[issue27578] inspect.findsource raises exception with empty __init__.py
kernc added the comment: The proposed patch doesn't break any interfaces. `inspect.getsource/.getsourcelines()` still raise `OSError` if the source is unretrievable. `linecache.getlines()` is undocumented, but the change retains perfect compatibility with *docstrings* of both `linecache.getlines()` which is affected and `linecache.updatecache()` which is touched. -- ___ Python tracker <https://bugs.python.org/issue27578> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27578] inspect.findsource raises exception with empty __init__.py
Change by kernc : -- keywords: +patch pull_requests: +20006 stage: -> patch review pull_request: https://github.com/python/cpython/pull/20809 ___ Python tracker <https://bugs.python.org/issue27578> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27578] inspect.findsource raises exception with empty __init__.py
Change by kernc : -- nosy: +kernc versions: +Python 3.10, Python 3.9 ___ Python tracker <https://bugs.python.org/issue27578> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30533] missing feature in inspect module: getmembers_static
Change by kernc : -- nosy: +kernc ___ Python tracker <https://bugs.python.org/issue30533> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27069] webbrowser creates zombi processes in the background mode
Change by kernc : -- nosy: +kernc versions: +Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue27069> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17972] inspect module docs omits many functions
Change by kernc : -- nosy: +kernc ___ Python tracker <https://bugs.python.org/issue17972> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33337] Provide a supported Concrete Syntax Tree implementation in the standard library
Change by kernc : -- nosy: +kernc ___ Python tracker <https://bugs.python.org/issue7> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24119] Carry comments with the AST
Change by kernc : -- nosy: +kernc ___ Python tracker <https://bugs.python.org/issue24119> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34624] -W option and PYTHONWARNINGS env variable does not accept module regexes
Change by kernc : -- nosy: +kernc ___ Python tracker <https://bugs.python.org/issue34624> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9338] argparse optionals with nargs='?', '*' or '+' can't be followed by positionals
Change by kernc : -- nosy: +kernc ___ Python tracker <https://bugs.python.org/issue9338> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22543] -W option cannot use non-standard categories
Change by kernc : -- nosy: +kernc ___ Python tracker <https://bugs.python.org/issue22543> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29620] unittest.TestCase.assertWarns raises RuntimeEror if sys.modules changes size
Change by kernc <kernc...@gmail.com>: -- keywords: +patch pull_requests: +4699 stage: -> patch review ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue29620> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29620] unittest.TestCase.assertWarns raises RuntimeEror if sys.modules changes size
New submission from kernc: If any of the objects in sys.modules is a module-like object that performs some additional imports in its __getattribute__ (as appropriate) handler, the following simple unit test test case: import unittest import warnings ... # Ensure one of the imported modules is a module-like object as above class Case(unittest.TestCase): def test_assertWarns(self): with self.assertWarns(UserWarning): warnings.warn('Some warning') fails with: == ERROR: test_assertWarns (example.Case) -- Traceback (most recent call last): File "/tmp/example.py", line 9, in test_assertWarns with self.assertWarns(UserWarning): File "/usr/lib/python3.4/unittest/case.py", line 205, in __enter__ for v in sys.modules.values(): RuntimeError: dictionary changed size during iteration -- The problem is in the iteration over sys.modules in unittest.case._AssertWarnsContext.__enter__() and accessing every module's __warningregistry__ attribute. On this access, the module-like objects may perform arbitrary actions including importing of further modules which extends sys.modules. https://github.com/python/cpython/blob/16ea19fc6653ee4ec1be7cd0206073962119ac08/Lib/unittest/case.py#L226-L227 The simple proposed fix with no foreseen side-effects is to wrap sys.modules.values() call as a tuple(). -- components: Library (Lib) messages: 288370 nosy: kernc priority: normal severity: normal status: open title: unittest.TestCase.assertWarns raises RuntimeEror if sys.modules changes size type: behavior versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29620> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26303] Shared execution context between doctests in a module
New submission from kernc: The doctest execution context documentation [0] says the tests get shallow *copies* of module's globals, so one test can't mingle with results of another. This makes it impossible to make literate modules such as: """ This module is about reusable doctests context. Examples Let's prepare something the later examples can work with: >>> import foo >>> result = foo.Something() 2 """ class Bar: """ Class about something. >>> bar = Bar(foo) >>> bar.uses(foo) True """ def baz(self): """ Returns 3. >>> result + bar.baz() 5 """ return 3 I.e. one has to instantiate everything in every single test. The documentation says one can pass their own globals as `glob=your_dict`, but it doesn't mention the dict is *cleared* after the test run. Please acknowledge the use case of doctests in a module sharing their environment and results sometimes legitimately exists, and to make it future-compatible, please amend the final paragraph of the relevant part of documentation [0] like so: You can force use of your own dict as the execution context by passing `globs=your_dict` to `testmod()` or `testfile()` instead, e.g., to have all doctests in a module use the _same_ execution context (sharing variables), define a context like so: class Context(dict): def copy(self): return self def clear(self): pass and use it, optionally prepopulated with `M`'s globals: doctest.testmod(module, glob=Context(module.__dict__.copy())) Thank you! [0]: https://docs.python.org/3/library/doctest.html#what-s-the-execution-context -- assignee: docs@python components: Documentation messages: 259731 nosy: docs@python, kernc priority: normal severity: normal status: open title: Shared execution context between doctests in a module type: enhancement versions: Python 3.6 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26303> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26303] Shared execution context between doctests in a module
kernc added the comment: The use case is not unpopular [1] and with unambiguous examples like >>> arr = np.arange(5) >>> my_sum(arr) 10 (i.e., without importing numpy as np everywhere), it also makes a lot of sense. [1]: http://stackoverflow.com/questions/13106118/object-reuse-in-python-doctest/35242443 -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26303> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22253] ConfigParser does not handle files without sections
kernc added the comment: I am dubious that there are any with a mixture of both sections and additional option lines at the top without a section. rsyncd.conf [1] is one such example, and I wouldn't say there aren't countless more in the wild. Anyone writing an app and planning to parse a .ini file can add [Start] or [Setup] at the top. Indeed. Here lies the problem of this unfortunate issue: MissingSectionHeaderError is only ever caught [9] to mitigate this **awful default behavior** and attach a dummy section at the top, as you say. Or can anyone care to propose another relevant use case for this poorly (un-) thought through exception? I think a more useful new configparser feature would be to keep comment lines and write them back out after a configuration is changed. While this is very much off-topic, configobj [3] does too seem to have done so since ages. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22253 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22253] ConfigParser does not handle files without sections
New submission from kernc: ConfigParser does not handle files that specify options in the global section (first option specified before any section is). This configuration behavior is present in the configuration files in the wild [1, 2], and while the naive workaround is simple, ... really?! The support for section-less configuration would also play nice with various POSIX-compatible config files (think /etc/default/*, /etc/os-release, ...). Ideally, the support could be enabled by default or only when `strict=False` constructor argument is supplied. The options in this global section could likely be accessed in the empty ('') section, e.g. `config.get('', 'option')`. Thus, ConfigParser could finally really replace the venerable ConfigObj [3]. [1]: http://stackoverflow.com/a/22501121/ [2]: https://www.google.com/search?q=MissingSectionHeaderError%3A+File+contains+no+section+headers [3]: http://www.voidspace.org.uk/python/configobj.html -- components: Library (Lib) messages: 225693 nosy: kernc priority: normal severity: normal status: open title: ConfigParser does not handle files without sections type: behavior versions: Python 2.7, Python 3.2, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22253 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22253] ConfigParser does not handle files without sections
kernc added the comment: I, for one, would actually prefer if global options were parsed by default and MissingSectionHeaderError was deprecated instead. From what little specification available, INI format does **not** require options be in sections [4, 5]. Additionally, Linux and Unix systems also use a similar file format for system configuration [6] and allowing global options being a (very sane) default would nicely fill this use case as well. In general, the format is not well defined [6], so choice of name `strict` for an argument is kind of odd too. What is it conforming to? It may be my sole opinion that parsing global options by default into a '' (or appropriate) section and deprecating MissingSectionHeaderError would benefit everyone [2, 9] and hinder few if any one at all [8, 9]. YMMV. [4]: http://en.wikipedia.org/wiki/INI_file#Sections [5]: http://en.wikipedia.org/wiki/INI_file#Global_properties [6]: http://en.wikipedia.org/wiki/INI_file [7]: http://en.wikipedia.org/wiki/INI_file#Varying_features [8]: http://nullege.com/pages/noresult/MissingSectionHeaderError [9]: https://github.com/search?l=pythonq=MissingSectionHeaderErrortype=Code -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22253 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com