2to3: Apply the `numliterals` fixer and skip the `long` fixer. #3232

Merged
merged 1 commit into from Apr 13, 2013

Projects

None yet

2 participants

@charris
Member
charris commented Apr 12, 2013

The numliterals fixer replaces the old style octal number like '01' by
'0o1' and removes the 'L' suffix specifying Python 2 long integers.

Octal values were previously mistakenly specified in some dates, those
uses have been corrected by removing the leading zeros.

Simply Removing the 'L' suffix should not be a problem, but in some
testing code it looks necessary, so in those places the Python long
constructor is used instead.

The 'long' type is no longer defined in Python 3. Because we need to
have it defined for Python 2 it is added to numpy/compat/np3k.py where
it is defined to 'int' for Python 3 and 'long' for Python 2. The long
fixer then needs to be skipped so that it doesn't undo the good work.

Closes #3074, #3067.

@njsmith njsmith and 1 other commented on an outdated diff Apr 13, 2013
numpy/core/numerictypes.py
-if sys.version_info[0] >= 3:
- # Py3K
- class long(int):
- # Placeholder class -- this will not escape outside numerictypes.py
- pass
+#if sys.version_info[0] >= 3:
+ ## Py3K
+ #class long(int):
+ ## Placeholder class -- this will not escape outside numerictypes.py
+ #pass
@njsmith
njsmith Apr 13, 2013 Member

It's a pretty staircase, but shouldn't it just be deleted? :-)

@charris
charris Apr 13, 2013 Member

Yeah, I remembered that after I pushed it.

@njsmith
Member
njsmith commented Apr 13, 2013

Otherwise +1

Also, you have a merge conflict

@charris
Member
charris commented Apr 13, 2013

Expected from the earlier merge. I'll fix things up.

@charris charris 2to3: Apply the `numliterals` fixer and skip the `long` fixer.
The numliterals fixer replaces the old style octal number like '01' by
'0o1' removes the 'L' suffix.

Octal values were previously mistakenly specified in some dates, those
uses have been corrected by removing the leading zeros.

Simply Removing the 'L' suffix should not be a problem, but in some
testing code it looks neccesary, so in those places the Python long
constructor is used instead.

The 'long' type is no longer defined in Python 3. Because we need to
have it defined for Python 2 it is added to numpy/compat/np3k.py where
it is defined as 'int' for Python 3 and 'long' for Python 2. The `long`
fixer then needs to be skipped so that it doesn't undo the good work.

Closes #3074, #3067.
7f5af37
@charris charris merged commit 688bc60 into numpy:master Apr 13, 2013

1 check passed

default The Travis build passed
Details
@charris charris deleted the charris:2to3-apply-numliterals-fixer branch Apr 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment