[Patches] [ python-Patches-1720897 ] fix 1668596: copy datafiles properly when package_dir is ' '

SourceForge.net noreply at sourceforge.net
Wed May 30 21:01:50 CEST 2007


Patches item #1720897, was opened at 2007-05-17 14:13
Message generated for change (Comment added) made by draghuram
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1720897&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Distutils and setup.py
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Raghuram Devarakonda (draghuram)
Assigned to: Nobody/Anonymous (nobody)
Summary: fix 1668596: copy datafiles properly when package_dir is ' '

Initial Comment:

This patch fixes http://www.python.org/sf/1668596. If package_dir is '', there is no need to remove package_dir part from data file path names.

I am also attaching 1668596_test.tar.gz. This has the directory I used to test the patch (both on Linux and Windows XP). I will need some more time to come up with a real test case that can be submitted as patch. I am hoping that if there is some one out there who is familiar with distutils test setup, they may be able to come up with a test case quicker than me.

----------------------------------------------------------------------

>Comment By: Raghuram Devarakonda (draghuram)
Date: 2007-05-30 15:01

Message:
Logged In: YES 
user_id=984087
Originator: YES

File Added: buildpy_patch.diff

----------------------------------------------------------------------

Comment By: Raghuram Devarakonda (draghuram)
Date: 2007-05-30 15:00

Message:
Logged In: YES 
user_id=984087
Originator: YES


errebepe, Thanks for the comments. I incorporated your suggestions about
the test case. It will now check explicitly for DistutilsFileError and
calls self.fail() if it gets this exception. I removed parens in "if
(src_dir)" as well.

I considered "plen = len(src_dir)+1 if src_dir else 0" form but I found it
difficult to follow compared to an explicit "if".

As to adding a docstring to the test case, I vaguely remember seeing some
comment about not having docstrings in test functions. I also don't find
docstrings in any of the test functions (found with a quick look at less
test_*.py output).





----------------------------------------------------------------------

Comment By: Rodrigo Bernardo Pimentel (errebepe)
Date: 2007-05-30 13:58

Message:
Logged In: YES 
user_id=374783
Originator: NO

+1 on the fix.

I do have a few minor suggestions, however. In the fix itself, the parens
in "(src_dir)" are still there. If the fix will only be applied in >= 2.5,
you might also use the "plen = len(src_dir)+1 if src_dir else 0" form.

As for the test, since you're testing a very specific error scenario
(Distribution.run_commands raising DistutilsFileError), I'd suggest
catching the exception and using "self.fail", so that testing the unfixed
code fails instead of issues an error. Since you expect the error to occur
inside run_commands, I'd put the try...except block around the
"dist.run_commands()" only, as in:

# Auxiliary variable, since you need cleanup and self.fail exits before
"finally":
error = False
try:
....dist.run_commands()
except DistutilsFileError:
....error = True
finally:
....os.chdir(cwd)
if error:
....self.fail("run_commands fails with no package_dir")

Gustavo Niemeyer also mentioned you should add a dosctring to the test
explaining what exactly it's testing.

To sum it up, I recommend commit of this patch regardless of my comments
above, but I hope they're taken into consideration :)

----------------------------------------------------------------------

Comment By: Raghuram Devarakonda (draghuram)
Date: 2007-05-30 13:19

Message:
Logged In: YES 
user_id=984087
Originator: YES

Thanks for reviewing. As for parens, they don't exist in the current
patch. Right? I removed them quite some time back.

----------------------------------------------------------------------

Comment By: Phillip J. Eby (pje)
Date: 2007-05-30 12:31

Message:
Logged In: YES 
user_id=56214
Originator: NO

+1 on this approach; recommend commit of this patch (note, however, that
the parens in "if (src_dir):" are redundant).

----------------------------------------------------------------------

Comment By: Raghuram Devarakonda (draghuram)
Date: 2007-05-21 14:24

Message:
Logged In: YES 
user_id=984087
Originator: YES


I managed to create a test case (is part of the patch now). I ran it on
Linux and Windows XP and in both cases, it properly tests the problem. 


----------------------------------------------------------------------

Comment By: Raghuram Devarakonda (draghuram)
Date: 2007-05-21 14:22

Message:
Logged In: YES 
user_id=984087
Originator: YES

File Added: buildpy_patch.diff

----------------------------------------------------------------------

Comment By: Raghuram Devarakonda (draghuram)
Date: 2007-05-17 14:25

Message:
Logged In: YES 
user_id=984087
Originator: YES

File Added: build_py.diff

----------------------------------------------------------------------

Comment By: Raghuram Devarakonda (draghuram)
Date: 2007-05-17 14:17

Message:
Logged In: YES 
user_id=984087
Originator: YES

File Added: 1668596_test.tar.gz

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1720897&group_id=5470


More information about the Patches mailing list