This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: function splitextTest does not return expected value
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6
Status: closed Resolution: duplicate
Dependencies: Superseder: os.path.splitext documentation needs typical example
View: 35183
Assigned To: Nosy List: Divya Rani, serhiy.storchaka, steven.daprano, xtreak
Priority: normal Keywords:

Created on 2018-12-24 04:52 by Divya Rani, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg332407 - (view) Author: Divya Rani (Divya Rani) Date: 2018-12-24 04:52
1. For input ".blah." output is "." 
2. For input "..." output is "..." 

results produced by the function are wrong according to the test suite provided by guava.
msg332410 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-12-24 05:47
Thanks for the report

> 1. For input ".blah." output is "." 

Please see issue35538

> 2. For input "..." output is "..." 

Please find the tests at

For completeness this is the behavior in master

Python 3.8.0a0 (heads/master:284b787612, Dec 23 2018, 23:11:33)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.splitext("...")
('...', '')
>>> os.path.splitext(".blah.")
('.blah', '.')

You can find links to other discussions in mailing list and other issues raised about this behavior at . Though this might be different from the behavior of guava I think this is something discussed extensively in the mailing list and finally to go with this behavior. So I don't think this is a bug but a behavior difference between guava and CPython implementation.
msg332411 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2018-12-24 05:51
Please provide a proper reproducible bug report. Don't make us GUESS what function you are referring to.

I don't know any "splitextTest" function that you describe in the bug report title. Do you mean os.path.splitext? Then you should say so. If not, then what function are you referring to?

What results do you expect, why do you expect them, and what results do you get?

Why should we care what test results some Java library returns? Maybe they've got it wrong, or maybe their function just works differently from ours. Unless this function is documented as being exactly compatible with the Java code you link to, I don't think it is very important what guava does.

Perhaps you should raise a bug report at Guava and tell them that according to the Python language, their function is wrong.

The os.path.splitext function is documented as returning the file extension as either the empty string "" or beginning with a single period, and leading dots are not part of the extension. So the examples you show are correct, if you are talking about os.path.splitext. If you are talking about something else, please explain what.
msg332412 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-24 06:02
As Karthikeyan said, (1) is a duplicate of issue35538. This is expected behavior.

(2) is a duplicate of issue35183 which is still discussed.

I do not know what relations do tests for third-party Java library have with the Python stdlib. Note that that tests imply that the extension of ".." is ".", that is considered obviously wrong.
Date User Action Args
2022-04-11 14:59:09adminsetgithub: 79757
2018-12-24 06:02:32serhiy.storchakasetstatus: open -> closed

superseder: os.path.splitext documentation needs typical example

nosy: + serhiy.storchaka
messages: + msg332412
resolution: duplicate
stage: resolved
2018-12-24 05:51:15steven.dapranosetnosy: + steven.daprano
messages: + msg332411
2018-12-24 05:47:16xtreaksetnosy: + xtreak
messages: + msg332410
2018-12-24 04:52:32Divya Ranicreate