[issue15377] os.path.join() error misleading with path1=None
New submission from Chris Jerdonek chris.jerdo...@gmail.com: The error message for os.path.join() is misleading when the first argument is None. The message should probably say something about mixing None and strings. Python 3.3.0b1 (default:f954ee489896, Jul 16 2012, 22:42:29) [GCC 4.2.1 Compatible Apple Clang 3.1 (tags/Apple/clang-318.0.58)] on darwin import os os.path.join(None, 'a') Traceback (most recent call last): File stdin, line 1, in module File .../cpython/Lib/posixpath.py, line 89, in join components.) from None TypeError: Can't mix strings and bytes in path components. -- components: Library (Lib) messages: 165685 nosy: cjerdonek priority: normal severity: normal status: open title: os.path.join() error misleading with path1=None versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15377 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15377] os.path.join() error misleading with path1=None
Changes by Hynek Schlawack h...@ox.cx: -- nosy: +hynek ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15377 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15377] os.path.join() error misleading with path1=None
Hynek Schlawack h...@ox.cx added the comment: I propose the following patch (against 3.2) that does the right thing. -- keywords: +patch nosy: +ncoghlan, pitrou stage: - patch review Added file: http://bugs.python.org/file26414/nicer-error-for-none.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15377 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15377] os.path.join() error misleading with path1=None
Changes by Hynek Schlawack h...@ox.cx: -- assignee: - hynek versions: +Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15377 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15377] os.path.join() error misleading with path1=None
Nick Coghlan ncogh...@gmail.com added the comment: I'd be more inclined to tighten up the check for the can't mix message to something like: valid_types = all(isinstance(s, (str, bytes, bytearray)) for s in (a, ) + p) if valid_types: # Must have a mixture of text and binary data raise TypeError(Can't mix strings and bytes in path components.) raise If people pass in something that isn't a valid argument *at all*, then I'm fine with just letting the underlying exception pass through. The str/bytes case is just worth special-casing because either on their own *are* valid arguments. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15377 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15377] os.path.join() error misleading with path1=None
Hynek Schlawack h...@ox.cx added the comment: Yeah, we talked about that exact think with Antoine on IRC. New proposal. -- Added file: http://bugs.python.org/file26415/nicer-error-for-none-v2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15377 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15377] os.path.join() error misleading with path1=None
Nick Coghlan ncogh...@gmail.com added the comment: Looks good to me -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15377 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15377] os.path.join() error misleading with path1=None
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 5553a53a230a by Hynek Schlawack in branch '3.2': #15377: Make posixpath.join() more strict when checking for str/bytes mix http://hg.python.org/cpython/rev/5553a53a230a New changeset d087ef80372d by Hynek Schlawack in branch 'default': #15377: Make posixpath.join() more strict when checking for str/bytes mix http://hg.python.org/cpython/rev/d087ef80372d -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15377 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15377] os.path.join() error misleading with path1=None
Hynek Schlawack h...@ox.cx added the comment: Fine! :) -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15377 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com