[issue17174] Posix os.path.join should raise TypeError when passed unusable type

2014-09-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Fixed in issue22034. See also issue21883.

--
nosy: +serhiy.storchaka
resolution:  - out of date
stage:  - resolved
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17174
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17174] Posix os.path.join should raise TypeError when passed unusable type

2013-02-09 Thread Thomas Scrace

New submission from Thomas Scrace:

Currently os.path.join will raise an AttributeError if passed an argument that 
does not have an endswith() method.

A try/except around the offending line would let us raise a more helpful 
TypeError:

except AttributeError as e:
bad = e.args[0].split()[0]
raise TypeError(object of type {} is not valid as a path
component.format(type(bad)))

--
components: Library (Lib)
messages: 181762
nosy: terry.reedy, thomas.scrace
priority: normal
severity: normal
status: open
title: Posix os.path.join should raise TypeError when passed unusable type
type: enhancement
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17174
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17174] Posix os.path.join should raise TypeError when passed unusable type

2013-02-09 Thread Janzert

Janzert added the comment:

While the current error message is a bit generic, I rather like that it tells 
you exactly why the type/object passed couldn't be used.

--
nosy: +Janzert

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17174
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17174] Posix os.path.join should raise TypeError when passed unusable type

2013-02-09 Thread Eric V. Smith

Eric V. Smith added the comment:

I think this change should not be made: it's a slippery slope, because there 
are thousands of places in the stdlib where a similar change could be made.

It's the nature of duck typing that you're not going to get a great error 
message everywhere you pass in the wrong type. Python programmers just have to 
learn this and understand it's a source of sometimes unobvious error messages.

If, despite my concerns, this change is still made, I think it is important 
that any new error message not mention str, or any list of accepted types. 
The proposal in msg181762 is good enough: just say that whatever type was used 
isn't acceptable. For example: there are a number of path object proposals 
floating around, and it's possible one of those could be used with os.path.join 
despite it not being a str.

--
nosy: +eric.smith

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17174
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com