Skip to content

Fix import-time DeprecationWarning on Python 3.5 #11798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 10, 2015

Conversation

embray
Copy link
Contributor

@embray embray commented Dec 8, 2015

Fixes the following:

$ python3.5 -Wall
Python 3.5.0 (default, Sep 18 2015, 09:31:01) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas.tslib
pandas/__init__.py:7: DeprecationWarning: bad escape \s
  from pandas import hashtable, tslib, lib

In Python 3.5 re.sub replacement patterns containing unrecognized character escapes are deprecated. This raw string format is needed to substitute \s literally.

…racter escapes are deprecated. This raw string format is needed to substitute \s literally.
@jreback
Copy link
Contributor

jreback commented Dec 9, 2015

any idea why this doesn't show the same warning? (this is not in cython)

(py3.5)bash-3.2$ python -Wall
Python 3.5.0 |Continuum Analytics, Inc.| (default, Oct 20 2015, 14:39:26) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from re import compile as re_compile
>>> re_compile('\s+')
re.compile('\\s+')

@jreback jreback added the Deprecate Functionality to remove in pandas label Dec 9, 2015
@embray
Copy link
Contributor Author

embray commented Dec 9, 2015

@jreback This doesn't affect re.compile() since to it \s is a recognized escape sequence in the context of a regular expression. In a replacement pattern to re.sub, however, it is not a meaningful escape sequence (in the regular expression language), so it needs to be passed literally \\s in order for it to replace with the literal \s.

@jreback jreback added Clean and removed Deprecate Functionality to remove in pandas labels Dec 10, 2015
@jreback jreback added this to the 0.18.0 milestone Dec 10, 2015
jreback added a commit that referenced this pull request Dec 10, 2015
Fix import-time DeprecationWarning on Python 3.5
@jreback jreback merged commit 084f715 into pandas-dev:master Dec 10, 2015
@jreback
Copy link
Contributor

jreback commented Dec 10, 2015

thanks!

@embray embray deleted the fix-python3.5-deprecation-warning branch December 10, 2015 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants