[issue45987] os.chdir in unittest's test case causes RecursionError on Windows
New submission from Toshihiro Kamiya : When I was writing unit tests, I noticed that os.chdir in the unittest test case failed with RecursionError. It seems to work fine on Ubuntu 20.04, but fails on Windows 10 (might fail on macOS). The attached file is a minimal code to reproduce this. When I run it, I got an error message as follows ``` PS C:\Users\toshihiro\tmp> python .\test_chdir_fails.py Traceback (most recent call last): File "C:\Users\toshihiro\tmp\test_chdir_fails.py", line 11, in unittest.main() File "C:\Users\toshihiro\AppData\Local\Programs\Python\Python39\lib\unittest\main.py", line 101, in __init__ self.runTests() (snip) File "C:\Users\toshihiro\AppData\Local\Programs\Python\Python39\lib\traceback.py", line 493, in __init__ context = TracebackException( [Previous line repeated 487 more times] RecursionError: maximum recursion depth exceeded PS C:\Users\toshihiro\tmp> ``` The version of python was: Python 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32 Regards, -- components: Library (Lib) files: test_chdir_fails.py messages: 407711 nosy: tos-kamiya priority: normal severity: normal status: open title: os.chdir in unittest's test case causes RecursionError on Windows type: crash versions: Python 3.9 Added file: https://bugs.python.org/file50476/test_chdir_fails.py ___ Python tracker <https://bugs.python.org/issue45987> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45987] os.chdir in unittest's test case causes RecursionError on Windows
Toshihiro Kamiya added the comment: Sorry, the "(snip)" means that it was omitted because it was too long. I' ll attach a screenshot. -- Added file: https://bugs.python.org/file50477/FF2dfQ_acAc497b.png ___ Python tracker <https://bugs.python.org/issue45987> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45987] os.chdir in unittest's test case causes RecursionError on Windows
Toshihiro Kamiya added the comment: Thank you, eryksun, for pointing out the cause of the problem. I have modified the test script and it can now be run on Windows. The attached file is a revised version of the reproduction script, which reflects the modifications made to the test script to prevent the error. -- resolution: -> not a bug stage: -> resolved status: open -> closed Added file: https://bugs.python.org/file50478/test_chdir_wo_fail.py ___ Python tracker <https://bugs.python.org/issue45987> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45987] os.chdir in unittest's test case causes RecursionError on Windows
Toshihiro Kamiya added the comment: I think it may be difficult to understand the error message that deleting a directory causes "RecursionError or stack overflow", though. I hope the issue reported as msg377358 will be resolved in some way. -- ___ Python tracker <https://bugs.python.org/issue45987> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6830] Some uniformness in defaultdict
New submission from Toshihiro Kamiya : I found the syntax of collections.defaultdict is confusing, at least to me. When I need a defaultdict of int, that is, a defaultdict which contains int objects, I can write simply: a = defaultdict(int) However, when I want a defaultdict of defaultdict of something, I can't write: d = defaultdict(defaultdict(int)) This raises TypeError. I understand the argument of defaultdict is not a type (or class), but a factory by definition. So I should to write: d = defaultdict(lambda: defaultdict(int)) But this syntax is somehow confusing to me. Am I missing some important feature of defaultdict? The workaround that I've found is: import collections class __Helper(object): def __getitem__(self, ctor): return lambda: collections.defaultdict(lambda: ctor()) genericdefaultdict = __Helper() This helper introduce some generics flavor in defaultdict. The above cases can be spelt out: a = genericdefaultdict[int]() d = genericdefaultdict[genericdefaultdict[int]]() -- components: Library (Lib) files: ddh.py messages: 92193 nosy: t-kamiya severity: normal status: open title: Some uniformness in defaultdict type: feature request versions: Python 2.6 Added file: http://bugs.python.org/file14824/ddh.py ___ Python tracker <http://bugs.python.org/issue6830> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5778] sys.version format differs between MSC and GCC
New submission from Toshihiro Kamiya : The value of sys.version includes a new-line char in GCC build. '2.5.2 (r252:60911, Oct 5 2008, 19:24:49) \n[GCC 4.3.2]' MSC build doesn't. '2.6.2 (r262:71605, Apr 14 2009, 22:46:50) [MSC v.1500 64 bit (AMD64)]' This seems a kind of pitfall for the developers who use this variable. -- components: Build messages: 86060 nosy: t-kamiya severity: normal status: open title: sys.version format differs between MSC and GCC versions: Python 2.5 ___ Python tracker <http://bugs.python.org/issue5778> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com