[issue9884] The 4th parameter of method always None or 0 on x64 Windows.
New submission from Owen : OS: Windows 2003STD x64 en I have try to call python method from c++ dll by "WINFUNCTYPE". But the 4th parameter is always None or 0 if the type is int or void* (float is works fine). Following is the part of source code: ==code== import sys from ctypes import * windll.LoadLibrary("testPy2.dll") # def test3(param1,param2,param3,param4,param5,param6,param7,param8,param9,param10): print("") print(param1) print(param2) print(param3) # the 4th param4 is always 0. print(param4) print(param5) print(param6) print(param7) print(param8) print(param9) print(param10) print("") return 20 C_METHOD_TYPE4 = WINFUNCTYPE(c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32) windll.testPy2.fntestPy7(9,C_METHOD_TYPE4(test3)) ==code== To my knowledge, both visual c++ and gcc use registers for the first few parameters, and then after that use the stack. Maybe this is the reason. I have attached some simple codes for reproduce this issue. issues - testPy2 <- source code of the dll - test.py <- python file to reproduce the issue - testPy2.dll <- the dll to reproduce the issue -- components: Windows files: issues.zip messages: 116649 nosy: J2.NETe priority: normal severity: normal status: open title: The 4th parameter of method always None or 0 on x64 Windows. versions: Python 2.7, Python 3.1 Added file: http://bugs.python.org/file18907/issues.zip ___ Python tracker <http://bugs.python.org/issue9884> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9884] The 4th parameter of method always None or 0 on x64 Windows.
Changes by Owen : -- type: -> behavior ___ Python tracker <http://bugs.python.org/issue9884> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9884] The 4th parameter of method always None or 0 on x64 Windows.
Owen added the comment: Please reproduce this issue by 64bit Python. -- ___ Python tracker <http://bugs.python.org/issue9884> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9884] The 4th parameter of method always None or 0 on x64 Windows.
Owen added the comment: Note: This issue also occurs on other 64 bit windows OS(i.e. windows xp 64bit) Load "testPy2.dll" needs vc++ runtime library (http://download.microsoft.com/download/2/d/6/2d61c766-107b-409d-8fba-c39e61ca08e8/vcredist_x64.exe) Update "testPy2.dll", use this to reproduce the issue. python code: import sys from ctypes import * windll.LoadLibrary("testPy2.dll") # def test3(param1,param2,param3,param4,param5,param6,param7,param8,param9,param10): print("") print(param1) print(param2) print(param3) print(param4) print(param5) print(param6) print(param7) print(param8) print(param9) print(param10) print("") return 20 C_METHOD_TYPE4 = WINFUNCTYPE(c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32) windll.testPy2.fntestPy7(9,C_METHOD_TYPE4(test3)) # def test4(param1,param2,param3,param4,param5,param6,param7,param8,param9,param10): print("") print(param1) print(param2) print(param3) print(param4) print(param5) print(param6) print(param7) print(param8) print(param9) print(param10) print("") return 20 C_METHOD_TYPE5 = WINFUNCTYPE(c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32) windll.testPy2.fntestPy8(10,C_METHOD_TYPE5(test4)) # def test5(param1,param2,param3,param4,param5,param6,param7,param8,param9,param10): print("") print(param1) print(param2) print(param3) print(param4) print(param5) print(param6) print(param7) print(param8) print(param9) print(param10) print("") return 20 C_METHOD_TYPE6 = WINFUNCTYPE(c_int32, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_float, c_float) windll.testPy2.fntestPy9(11,C_METHOD_TYPE6(test5)) -- Added file: http://bugs.python.org/file18929/testPy2.dll ___ Python tracker <http://bugs.python.org/issue9884> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9884] The 4th parameter of method always None or 0 on x64 Windows.
Owen added the comment: I tested this issue in Python2.7.1, Python3.1.3 and Python 3.2rc1. It's still can reproduce. Would you please check this "Callback functions" issue? -- ___ Python tracker <http://bugs.python.org/issue9884> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9884] The 4th parameter of method always None or 0 on x64 Windows.
Owen added the comment: yes, I tried lots of types. The issue still happens. The same case in Ubuntu and Mac were works well. -- ___ Python tracker <http://bugs.python.org/issue9884> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9884] The 4th parameter of method always None or 0 on x64 Windows.
Owen added the comment: wow~~~ It works on my PC too (Windows 2003 STD x64). Thanks. -- ___ Python tracker <http://bugs.python.org/issue9884> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9884] The 4th parameter of method always None or 0 on x64 Windows.
Owen added the comment: Thanks, this issue has been fixed. :-) fixing revisions: r88284 (3.2), r88285 (3.1) and r88286 (2.7) -- resolution: -> fixed status: open -> closed ___ Python tracker <http://bugs.python.org/issue9884> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45458] "\W" pattern with re.ASCII flag is not equivalent to "[^a-zA-Z0-9_]"
New submission from Owen : "\W" regex pattern, when used with `re.ASCII`, is expected to have the same behavior as "[^a-zA-Z0-9_]" (see [1]). For example, the following `sub()` call ``` >>> re.sub('\W', '', '½ a', re.ASCII) '½a' ``` should return the same as this one: ``` >>> re.sub('[^a-zA-Z0-9_]', '', '½ a', re.ASCII) 'a' ``` But it does not. [1] https://docs.python.org/3/library/re.html#regular-expression-syntax -- components: Regular Expressions messages: 403810 nosy: ezio.melotti, mrabarnett, owentrigueros priority: normal severity: normal status: open title: "\W" pattern with re.ASCII flag is not equivalent to "[^a-zA-Z0-9_]" type: behavior versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue45458> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12853] global name 'r' is not defined in upload.py
New submission from Russell Owen : When using distutils to upload code to PyPI I get the following message (but the upload is successful): {{{ Traceback (most recent call last): File "setup.py", line 60, in zip_safe = False, # icons (e.g. as used by RO.Wdg.GrayImageDispWdg) are not retrieved in a zip-safe way File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup dist.run_commands() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands self.run_command(cmd) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command cmd_obj.run() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/upload.py", line 60, in run self.upload_file(command, pyversion, filename) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/upload.py", line 180, in upload_file msg = '\n'.join(('-' * 75, r.read(), '-' * 75)) NameError: global name 'r' is not defined }}} A look at the current source code shows that there is indeed no variable "r". I'm not sure what was intended but it seems likely that it would be possible to replace r.read() by reason, status, or a combination of the two. -- messages: 143162 nosy: reowen priority: normal severity: normal status: open title: global name 'r' is not defined in upload.py type: behavior versions: Python 2.7, Python 3.4 ___ Python tracker <http://bugs.python.org/issue12853> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10964] Mac installer need not add things to /usr/local
New submission from Russell Owen : The Mac installer alters the user's $PATH to put /Library/Frameworks/Python.Framework/Versions/Current/bin on the $PATH before /usr/local/bin and /usr/bin. This is a good idea in my opinion. But the installer *also* installs numerous symlinks in /usr/local/bin. These symlinks are redundant with altering the $PATH. Thus they are redundant. They are also make it difficult to switch versions of python because it's tricky to know which symlinks should be deleted (and the list may depend on the current version of python). This is problem for me because I often have to switch versions of Python while building binary installers for packages such as matplotlib. My request is for the Mac python installer to leave /usr/local/bin alone. For if there is a need to add symlinks to /usr/local/bin that I'm not seeing then my request is for an easy way to switch versions of python or at least get rid of the symlinks, e.g. a python version switcher script or symlink deletion script. -- assignee: ronaldoussoren components: Macintosh messages: 126661 nosy: reowen, ronaldoussoren priority: normal severity: normal status: open title: Mac installer need not add things to /usr/local type: feature request versions: Python 2.7 ___ Python tracker <http://bugs.python.org/issue10964> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2932] Documenting Python: Syntax"
New submission from Wallace Owen <[EMAIL PROTECTED]>: http://docs.python.org/doc/latex-syntax.html -- messages: 67142 nosy: owen severity: normal status: open title: Documenting Python: Syntax" __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2932> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2933] "Documenting Python: Syntax" bug
New submission from Wallace Owen <[EMAIL PROTECTED]>: The 'documenting Python' document, section 4.1, at this url: http://docs.python.org/doc/latex-syntax.html has an incorrect (but correctly spelled) word in one of it's sentences: Macros which take no parameters but which should not be followed by a word space do not need special treatment if the following character in the document source if not a name character (such as punctuation). The phrase "source if not a name" should be "source is not a name". By the way, in attempting to classify this bug within the parameters allowed, I observe that there is no correct 'Type' for this bug: none of the allowed choices seem to apply. It's not a "crash", "compile error", "resource usage", "security", "behavior", "performance" or "feature request". I figured "feature request" would ring the fewest alarm bells, so I used that. -- assignee: georg.brandl components: Documentation messages: 67143 nosy: georg.brandl, owen severity: normal status: open title: "Documenting Python: Syntax" bug type: feature request versions: Python 3.0 __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2933> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2933] "Documenting Python: Syntax" bug
Wallace Owen <[EMAIL PROTECTED]> added the comment: Thanks for the fast attention. One question: How do I access and use these docs? I went looking for the instructions on documenting, so when I contribute, the docs I do are in the right format. The url I was reading didn't have a '2.5' in it's path, it was: http://docs.python.org/doc/latex-syntax.html I navigated there by selecting "Browse Current Documentation" at "http://www.python.org/doc/ which took me directly to the 2.5.2 documentation page. If the 2.5 stuff isn't current, this link would appear to be bad. Should I submit a bug, or have I jammed my head too far up my ass to be useful? :^) // Wally On Wed, 2008-05-21 at 03:07 +, Benjamin Peterson wrote: > Benjamin Peterson <[EMAIL PROTECTED]> added the comment: > > Thanks for the report. However, since we have moved to a new doc format > (reST), we are not maintaining the 2.5 docs. > > -- > nosy: +benjamin.peterson > resolution: -> wont fix > status: open -> closed > versions: +Python 2.5 -Python 3.0 > > __ > Tracker <[EMAIL PROTECTED]> > <http://bugs.python.org/issue2933> > __ __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2933> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue799428] tk_focusNext() fails
Russell Owen added the comment: The bug still exists. Please assign this bug and patch to Martin Loewis if possible (I don't have privileges for that). -- nosy: +reowen type: -> behavior versions: +Python 2.5 -Python 2.3 Added file: http://bugs.python.org/file9483/Tkinter_patch.txt Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue799428> ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4017] Tkinter cannot find Tcl/Tk on Mac OS X
Changes by Russell Owen <[EMAIL PROTECTED]>: -- nosy: +reowen ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4017> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40017] Please support CLOCK_TAI in the time module.
New submission from Russell Owen : It is becoming common (at least in astronomy) to want to use TAI as a time standard because it is a uniform time with no leap seconds, and differs from UTC (standard computer clock time) by an integer number of seconds that occasionally changes. Linux offers a clock for TAI time: CLOCK_TAI. It would be very helpful to have this constant in the time module, e.g. for calling time.clock_gettime Caveat: linux CLOCK_TAI will return UTC time if the leap second table has not been set up. Both ntp and ptp can be configured to maintain this table. So this is a caveat worth mentioning in the docs. But I hope it is not sufficient reason to deny the request. -- components: Library (Lib) messages: 364633 nosy: r3owen priority: normal severity: normal status: open title: Please support CLOCK_TAI in the time module. type: enhancement versions: Python 3.8 ___ Python tracker <https://bugs.python.org/issue40017> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40017] Please support CLOCK_TAI in the time module.
Change by Russell Owen : -- keywords: +patch pull_requests: +18455 stage: -> patch review pull_request: https://github.com/python/cpython/pull/19096 ___ Python tracker <https://bugs.python.org/issue40017> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39758] StreamWriter.wait_closed() can hang indefinitely.
Russell Owen added the comment: I am also seeing this in Python 3.8.6. I am not using SSL, but am simply calling `await writer.wait_closed()` on an `asyncio.StreamWriter`. Sometimes it works quickly and sometimes it hangs indefinitely. -- nosy: +r3owen ___ Python tracker <https://bugs.python.org/issue39758> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39758] StreamWriter.wait_closed() can hang indefinitely.
Russell Owen added the comment: Regarding my previous comment: I have never seen this in Python 3.7 (though I see that this particular bug is listed as being present there) so it may be a different underlying issue. -- ___ Python tracker <https://bugs.python.org/issue39758> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35343] Importlib.reload has different behaviour in script and interactive mode
New submission from Owen Pembery : This may be a bug, or may be a hole in my understanding of how importlib.reload works. In short, when running importlib.reload in a script, it seems that a module is not reloaded before it is used, whereas running the same script a line at a time in interactive mode seems to reload the script. Relevant scripts are in the github repository: https://github.com/orpembery/python-reload-bug. I find the bug using python 3.5.2 on Ubuntu 16.04. The expected output from running python3 master.py is: 1 2 However, I instead find that the output is: 1 1 If I paste the commands in master.py into the interpreter one at a time, I get the expected behaviour: Python 3.5.2 (default, Nov 12 2018, 13:43:14) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from shutil import copy >>> >>> from importlib import reload >>> # Move a file ... copy('fn_1.py','fn.py') 'fn.py' >>> # Import it ... import fn >>> # Run it ... fn.fn() 1 >>> # Move a different file to the same location. ... copy('fn_2.py','fn.py') 'fn.py' >>> # Reload it ... reload(fn) >>> # Run it ... fn.fn() 2 However, if the commands in master.py are pasted in all at one (i.e., with a single CTRL-V keystroke), I obtain the unexpected behaviour: Python 3.5.2 (default, Nov 12 2018, 13:43:14) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from shutil import copy >>> from importlib import reload >>> >>> # Move a file ... copy('fn_1.py','fn.py') 'fn.py' >>> >>> # Import it ... import fn >>> >>> # Run it ... fn.fn() 1 >>> >>> # Move a different file to the same location. ... copy('fn_2.py','fn.py') 'fn.py' >>> >>> # Reload it ... reload(fn) >>> >>> # Run it ... fn.fn() 1 Possible causes: I'm very far from an expert, but it seems to be something to do with caching; running python3 -B master.py gives the expected behaviour. -- components: Library (Lib) messages: 330631 nosy: brett.cannon, orpembery priority: normal severity: normal status: open title: Importlib.reload has different behaviour in script and interactive mode versions: Python 3.5 ___ Python tracker <https://bugs.python.org/issue35343> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35343] Importlib.reload has different behaviour in script and interactive mode
Change by Owen Pembery : -- type: -> behavior ___ Python tracker <https://bugs.python.org/issue35343> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36770] stdlib - shutil.make_archive - add support for different ZIP compression method
New submission from Owen Chia : if you just want to use different zip compression method, no need to rewrite entire _make_zipfile function. e.g. >>> shutil.make_archive('archive', 'zip_lzma', '/path/to/whatever') -- components: Library (Lib) files: shutil.make_archive.patch keywords: patch messages: 341201 nosy: giampaolo.rodola, owenchia, tarek priority: normal severity: normal status: open title: stdlib - shutil.make_archive - add support for different ZIP compression method type: enhancement versions: Python 3.8 Added file: https://bugs.python.org/file48293/shutil.make_archive.patch ___ Python tracker <https://bugs.python.org/issue36770> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19809] Python get stuck in second Popen call
New submission from Owen Lin: If we call two subprocess.Popen simultaneously, the second one is blocked until the first one is finished. The attached file is a code snippet to reproduce this bug. I can reproduce the bug in version 2.7.3 and 2.7.6 very easily (in few seconds with the code). But it works fine on python3. Here is the backtrace of python == #0 0x7f0eba954d2d in read () at ../sysdeps/unix/syscall-template.S:82#1 0x005d8d10 in posix_read (self=0x0, args=(5, 1048576)) at ../Modules/posixmodule.c:6628#2 0x00486896 in PyCFunction_Call (func=, arg=(5, 1048576), kw=0x0)at ../Objects/methodobject.c:81#3 0x005278e4 in ext_do_call (func=, pp_stack=0x7fff1fc0ac80, flags=1, na=0, nk=0) at ../Python/ceval.c:4331 #4 0x005215cd in PyEval_EvalFrameEx ( f=Frame 0x298f800, for file /usr/lib/python2.7/subprocess.py, line 478, in _eintr_retry_call (func=, args=(5, 1048576)), throwflag=0) at ../Python/ceval.c:2705 #5 0x00523c2e in PyEval_EvalCodeEx (co=0x294b880, globals={'STDOUT': -2, '_has_poll': True, 'gc': , 'check_call': , 'mswindows': False, 'select': , 'list2cmdline': , '__all__': ['Popen', 'PIPE', 'STDOUT', 'call', 'check_call', 'check_output', 'CalledProcessError'], 'errno': , '_demo_posix': , '__package__': None, 'PIPE': -1, '_cleanup': http://bugs.python.org/file32868/test.py ___ Python tracker <http://bugs.python.org/issue19809> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2624] swig support in distutils should use the build and temp dirs
Changes by Russell Owen : -- nosy: +reowen ___ Python tracker <http://bugs.python.org/issue2624> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17370] PEP should note if it has been superseded
Changes by Owen Nelson : -- nosy: +Owen.Nelson ___ Python tracker <http://bugs.python.org/issue17370> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14156] argparse.FileType for '-' doesn't work for a mode of 'rb'
Change by Owen T. Heisler : -- nosy: -owenh ___ Python tracker <https://bugs.python.org/issue14156> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14156] argparse.FileType for '-' doesn't work for a mode of 'rb'
Change by Owen T. Heisler : -- nosy: +owenh ___ Python tracker <https://bugs.python.org/issue14156> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17545] os.listdir and os.path.join inconsistent on empty path
W. Owen Parry added the comment: Patch as described above. Comments appreciated. -- keywords: +patch Added file: http://bugs.python.org/file30367/issue17545.patch ___ Python tracker <http://bugs.python.org/issue17545> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16580] Add examples to int.to_bytes and int.from_bytes
W. Owen Parry added the comment: Patch adding examples + tests for equivalence. Comments appreciated. In particular, I'm not sure that the from_bytes example is simple enough to be useful: def from_bytes(bytes, byteorder, signed=False): if byteorder == 'little': little_ordered = list(bytes) elif byteorder == 'big': little_ordered = list(reversed(bytes)) n = sum(little_ordered[i] << i*8 for i in range(len(little_ordered))) if signed and little_ordered and (little_ordered[-1] & 0x80): n -= 1 << 8*len(little_ordered) return n -- keywords: +patch nosy: +woparry Added file: http://bugs.python.org/file30372/issue16580.patch ___ Python tracker <http://bugs.python.org/issue16580> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17545] os.listdir and os.path.join inconsistent on empty path
W. Owen Parry added the comment: I started working on a patch for this, but the more I think about it the less I am convinced it is wanted. The issue requests that os.listdir('') be equal to os.listdir('.') The given example of os.path.join doesn't follow this: >>> os.path.join('','aaa') 'aaa' >>> os.path.join('.','aaa') '.\\aaa' This makes sense: prepending an empty path should be a no-op, while prepending the current directory has a different meaning. It seems consistent in this case that listing an empty path and listing the current directory should have different meanings. Is there any other traction/use case for this change? -- nosy: +woparry ___ Python tracker <http://bugs.python.org/issue17545> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17545] os.listdir and os.path.join inconsistent on empty path
W. Owen Parry added the comment: I suggest that this is a documentation issue. I have seen three classes of functions is os and os.path i - those which operate on path names only (os.path.join, os.path.dirname, etc) and do not depend on the state of the file system. Since these are string manipulation functions, they treat '' as the empty string. ii - those which turn path names into valid paths via knowledge of the state of the file system (os.path.abspath, os.path.normpath, etc). These treat '' as an empty relative path and thus equivalent to the current directory. iii - those which operate on valid paths only and thus depend on the state of the file system (os.listdir, os.stat, os.path.relpath, os.path.exists, etc). '' is not a valid path so these functions throw an exception. The documentation should clearly state which class a function belongs to. I will provide a patch sometime this week. os.walk is an odd duck - it has class iii behaviour except that it returns an empty iterator instead of raising an exception. Note that it still distinguishes between '' (invalid path) and '.' (current directory) and so is not a good reason to change os.listdir: >>> [x for x in os.walk('')] [] >>> [x for x in os.walk('.')] [('.', [], [])] in an empty directory. -- ___ Python tracker <http://bugs.python.org/issue17545> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com