internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: Theano/Theano

Issue:
Deprecation warning for tensor.stack
In [the doc](http://deeplearning.net/software/theano/library/tensor/basic.html#theano.tensor.stack), the deprecation for `stack(*tensors)` is placed under the entry for `stack(tensors, axis=0)`, which is unclear whether there is a typo and `stack(tensors, axis=0)` is deprecated, or `stack(*tensors)` is deprecated but the warning is misplaced. I'm guessing it's the second one.



Discussion:
Thank you for pointing that out! You are right that it's the second one. The example of stack(tensors, axis=0) is also incomplete. I will fix this.


Resolving patch:
diff --git a/theano/tensor/basic.py b/theano/tensor/basic.py
--- a/theano/tensor/basic.py
+++ b/theano/tensor/basic.py
@@ -4024,9 +4024,10 @@ def shape_padaxis(t, axis):
 
 @constructor
 def stack(*tensors, **kwargs):
-    """Insert the arguments as slices into a tensor of 1 rank greater.
+    """Stack tensors in sequence on given axis (default is 0).
 
-    The size in dimension `axis` of the result will be equal to the number
+    Take a sequence of tensors and stack them on given axis to make a single
+    tensor. The size in dimension `axis` of the result will be equal to the number
     of tensors passed.
 
     Note: The interface stack(*tensors) is deprecated, you should use
@@ -4039,6 +4040,35 @@ def stack(*tensors, **kwargs):
     axis : int
         The index of the new axis. Default value is 0.
 
+    Examples
+    --------
+    >>> a = theano.tensor.scalar()
+    >>> b = theano.tensor.scalar()
+    >>> c = theano.tensor.scalar()
+    >>> x = theano.tensor.stack([a, b, c])
+    >>> x.ndim # x is a vector of length 3.
+    1
+    >>> a = theano.tensor.tensor4d()
+    >>> b = theano.tensor.tensor4d()
+    >>> c = theano.tensor.tensor4d()
+    >>> x = theano.tensor.stack([a, b, c])
+    >>> x.ndim # x is a 5d tensor.
+    5
+    >>> rval = x.eval(dict((t, np.zeros((2, 2, 2, 2))) for t in [a, b, c]))
+    >>> rval.shape # 3 tensors are stacked on axis 0
+    (3, 2, 2, 2, 2)
+    >>> x = theano.tensor.stack([a, b, c], axis=3)
+    >>> x.ndim
+    5
+    >>> rval = x.eval(dict((t, np.zeros((2, 2, 2, 2))) for t in [a, b, c]))
+    >>> rval.shape # 3 tensors are stacked on axis 3
+    (2, 2, 2, 3, 2)
+    >>> x = theano.tensor.stack([a, b, c], axis=-2)
+    >>> x.ndim
+    5
+    >>> rval = x.eval(dict((t, np.zeros((2, 2, 2, 2))) for t in [a, b, c]))
+    >>> rval.shape # 3 tensors are stacked on axis -2
+    (2, 2, 2, 3, 2)
     """
     # ---> Remove this when moving to the new interface:
     if not tensors and not kwargs:


Test patch:
Repository: Theano/Theano

Issue:
Ops creating variables without stack trace
This ticket is here to centralize a list of functions or Ops creating symbolic variables without a stack trace.
- `DimShuffle`. None of the following assign a stack trace to the output's `tag.trace`:
  - `x.T`
  - `x.dimshuffle(1, 0)`
  - `theano.tensor.transpose(x)`

Related to #3018.



Discussion:
DimShuffle.make_node call a_type.make_variable() instead of a_type.

Do work on this with too much duplication, who fix it?

On Tue, Jul 21, 2015 at 4:54 PM, Pascal Lamblin notifications@github.com
wrote:

> This ticket is here to centralize a list of functions or Ops creating
> symbolic variables without a stack trace.
> - DimShuffle. None of the following assign a stack trace to the
>   output's tag.trace:
>   - x.T
>   - x.dimshuffle(1, 0)
>   - theano.tensor.transpose(x)
> 
> Related to #3018 https://github.com/Theano/Theano/issues/3018.
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/Theano/Theano/issues/3190.

@lamblin @nouiz  , I'm interested in fixing this issue. I've been a user of theano for a while, but a new contributor. Could you please help with the fix ? :) 

I think you simply need to go in the file tensor/elemwise.py in the method
DimShuffle.make_node() and replace

```
    output = TensorType(dtype=input.type.dtype,
                        broadcastable=ob).make_variable()
```

by

```
    output = TensorType(dtype=input.type.dtype,
                        broadcastable=ob)()
```

That should fix all the case in this tickets, as they all generate
DimShuffle.

Than make a PR [1] to Theano. Be sure to test this on your side.

If you have questions, don't hesitate.

[1]
http://www.deeplearning.net/software/theano/dev_start_guide.html#dev-start-guide

On Sun, Nov 22, 2015 at 8:55 AM, Ramana Subramanyam <
notifications@github.com> wrote:

> @lamblin https://github.com/lamblin @nouiz https://github.com/nouiz ,
> I'm interested in fixing this issue. I've been a user of theano for a
> while, but a new contributor. Could you please help with the fix ? :)
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/Theano/Theano/issues/3190#issuecomment-158761590.


Resolving patch:
diff --git a/theano/tensor/elemwise.py b/theano/tensor/elemwise.py
--- a/theano/tensor/elemwise.py
+++ b/theano/tensor/elemwise.py
@@ -210,7 +210,7 @@ def make_node(self, _input):
                 ob.append(ib[value])
 
         output = TensorType(dtype=input.type.dtype,
-                            broadcastable=ob).make_variable()
+                            broadcastable=ob)()
 
         return Apply(self, [input], [output])
 


Test patch:
Repository: Theano/Theano

Issue:
Move the creating ops part of tutorial to the extending section.



Discussion:

Resolving patch:
diff --git a/doc/tutorial/extending_theano_solution_1.py b/doc/extending/extending_theano_solution_1.py
similarity index 100%
rename from doc/tutorial/extending_theano_solution_1.py
rename to doc/extending/extending_theano_solution_1.py
diff --git a/theano/tensor/signal/pool.py b/theano/tensor/signal/pool.py
--- a/theano/tensor/signal/pool.py
+++ b/theano/tensor/signal/pool.py
@@ -46,8 +46,9 @@ def max_pool_2d_same_size(input, patch_size):
 
 
 def pool_2d(input, ds, ignore_border=None, st=None, padding=(0, 0),
-                mode='max'):
-    """
+            mode='max'):
+    """Downscale the input by a specified factor
+
     Takes as input a N-D tensor, where N >= 2. It downscales the input image by
     the specified factor, by keeping only the maximum value of non-overlapping
     patches of size (ds[0],ds[1])
@@ -888,7 +889,7 @@ def grad(self, inp, grads):
         ggx, = grads
         return [theano.tensor.zeros_like(x),
                 Pool(self.ds, ignore_border=self.ignore_border,
-                      st=self.st, padding=self.padding, mode=self.mode)(ggx)]
+                     st=self.st, padding=self.padding, mode=self.mode)(ggx)]
 
 
 class DownsampleFactorMaxGradGrad(Op):


Test patch:
Repository: Theano/Theano

Issue:
Rename `BatchedDotOp` to `GpuBatchedDot`
This would be more consistent with the usual naming scheme.
We should still be backward compatible, if possible with a warning.



Discussion:

Resolving patch:
diff --git a/theano/sandbox/cuda/blas.py b/theano/sandbox/cuda/blas.py
--- a/theano/sandbox/cuda/blas.py
+++ b/theano/sandbox/cuda/blas.py
@@ -15,7 +15,7 @@
 from theano.tensor import as_tensor_variable
 
 
-class BatchedDotOp(GpuOp):
+class GpuBatchedDot(GpuOp):
     __props__ = ()
 
     def make_node(self, inp1, inp2):
@@ -216,7 +216,8 @@ def infer_shape(self, node, shapes):
         xshp, yshp = shapes
         return [xshp[:-1] + yshp[2:]]
 
-batched_dot = BatchedDotOp()
+batched_dot = GpuBatchedDot()
+BatchedDotOp = GpuBatchedDot()
 """
 Call cublasSgemmBatched. Take 2 3d tensor as input.
 """
diff --git a/theano/sandbox/cuda/opt.py b/theano/sandbox/cuda/opt.py
--- a/theano/sandbox/cuda/opt.py
+++ b/theano/sandbox/cuda/opt.py
@@ -33,7 +33,7 @@
 from theano.sandbox.cuda.type import CudaNdarrayType
 from theano.sandbox.cuda.blas import (
     gpu_dot22, gpu_dot22scalar, gpu_gemm_inplace, gpu_gemm_no_inplace, GpuConv,
-    BatchedDotOp, GpuCorrMM, GpuCorrMM_gradInputs, GpuCorrMM_gradWeights,
+    GpuBatchedDot, GpuCorrMM, GpuCorrMM_gradInputs, GpuCorrMM_gradWeights,
     GpuCorr3dMM, GpuCorr3dMM_gradInputs, GpuCorr3dMM_gradWeights)
 
 from theano.sandbox.cuda.blas import gpu_gemv_inplace
@@ -629,7 +629,7 @@ def gpu_batched_dot(x, y):
             x_ = x_.dimshuffle(0, "x", 1)
         if y.ndim == 2:
             y_ = y_.dimshuffle(0, 1, "x")
-        z = BatchedDotOp()(as_cuda_ndarray_variable(x_),
+        z = GpuBatchedDot()(as_cuda_ndarray_variable(x_),
                            as_cuda_ndarray_variable(y_))
         # unpad z shape
         if x.ndim == 2:


Test patch:
diff --git a/theano/sandbox/cuda/tests/test_blas.py b/theano/sandbox/cuda/tests/test_blas.py
--- a/theano/sandbox/cuda/tests/test_blas.py
+++ b/theano/sandbox/cuda/tests/test_blas.py
@@ -23,7 +23,7 @@
 from theano.tensor.tests.test_blas import BaseGemv, TestBlasStrides, TestGer
 from theano.sandbox.cuda.blas import gpu_gemv_no_inplace, gpu_gemv_inplace
 from theano.sandbox.cuda.blas import gpu_ger_inplace, gpu_ger_no_inplace
-from theano.sandbox.cuda.blas import batched_dot, BatchedDotOp
+from theano.sandbox.cuda.blas import batched_dot, GpuBatchedDot
 
 if theano.config.mode == 'FAST_COMPILE':
     mode_with_gpu = theano.compile.mode.get_mode('FAST_RUN').including('gpu')
@@ -121,9 +121,9 @@ def test_infer_shape(self):
         admat_val = my_rand(7, 4, 5)
         bdmat_val = my_rand(7, 5, 3)
         self._compile_and_check([admat, bdmat],
-                                [BatchedDotOp()(admat, bdmat)],
+                                [GpuBatchedDot()(admat, bdmat)],
                                 [admat_val, bdmat_val],
-                                BatchedDotOp)
+                                GpuBatchedDot)
 
 
 def test_dot22():
Repository: Theano/Theano

Issue:
Add tip in regarding mixed dtypes to profiling output.
See @lamblin's comment in #3964.

Context : the logistic regression example from the deep learning tutorials was used to provide an example of the output of Theano's profiling mode. However, in the profile output, it seems like one of the dot products has been kept in the graph because of float32/float64 dtypes (otherwise it could have been removed).



Discussion:
The code for that seems to already be [here](https://github.com/Theano/Theano/blob/master/theano/compile/profiling.py#L1367-L1378), we should investigate why it was not triggered, or displayed.

Oh, OK, actually in that case, that is a `Dot` between a vector and a matrix, which should have been optimized into a `Gemv`. The existing tip only looks for matrix-matrix dot products.
So indeed, a new tip should be added.


Resolving patch:
diff --git a/theano/compile/profiling.py b/theano/compile/profiling.py
--- a/theano/compile/profiling.py
+++ b/theano/compile/profiling.py
@@ -1391,6 +1391,16 @@ def exp_float32_op(op):
                           " generator supported on the GPU.", file = file)
                 break
 
+        # tip 6
+        for a in self.apply_time:
+            node = a
+            if (isinstance(node.op, T.Dot) and
+                len(set(i.dtype for i in node.inputs)) != 1):
+                print("  - You have a dot operation that has different dtype "
+                      " for inputs (%s). Make sure that the inputs have same "
+                      " dtype." % [i.type for i in node.inputs], file = file)
+                printed_tip = True
+
         if not printed_tip:
             print("  Sorry, no tip for today.", file = file)
 


Test patch:
Repository: Theano/Theano

Issue:
Bilinear_Upsampling requires to specify batch_size and num_input_channels
Referring to this line:
https://github.com/Theano/Theano/blob/master/theano/tensor/nnet/abstract_conv.py#L570

this piece of code doesn't work with `batch_size` and/or `num_input_channels` set to `None`
it requires to specify the dimensions as scalar values



Discussion:
Indeed. We should `input.shape[0]` and `input.shape[1]` instead if they are not None.


Resolving patch:
diff --git a/theano/tensor/nnet/abstract_conv.py b/theano/tensor/nnet/abstract_conv.py
--- a/theano/tensor/nnet/abstract_conv.py
+++ b/theano/tensor/nnet/abstract_conv.py
@@ -567,7 +567,7 @@ def bilinear_upsampling(input,
                                                subsample=(ratio, ratio),
                                                filter_flip=True)
 
-    return upsampled_mat.reshape((batch_size, num_input_channels,
+    return upsampled_mat.reshape((input.shape[0], input.shape[1],
                                   row * ratio, col * ratio))
 
 


Test patch:
diff --git a/theano/tensor/nnet/tests/test_abstract_conv.py b/theano/tensor/nnet/tests/test_abstract_conv.py
--- a/theano/tensor/nnet/tests/test_abstract_conv.py
+++ b/theano/tensor/nnet/tests/test_abstract_conv.py
@@ -687,6 +687,23 @@ def test_bilinear_upsampling_1D(self):
             up_mat_2d = self.get_upsampled_twobytwo_mat(input_x, ratio)
             utt.assert_allclose(f(), up_mat_2d, rtol=1e-06)
 
+    def test_bilinear_upsampling_reshaping(self):
+        # Test bilinear upsampling without giving shape information
+        # This method tests the bilinear_upsampling method
+        # without giving batch_size and num_input_channels
+        # upsampling for a ratio of two
+        input_x = np.array([[[[1, 2], [3, 4]]]], dtype=theano.config.floatX)
+
+        for ratio in [2, 3]:
+            for use_1D_kernel in [True, False]:
+                bilin_mat = bilinear_upsampling(input=input_x, ratio=ratio,
+                                                batch_size=None,
+                                                num_input_channels=None,
+                                                use_1D_kernel=use_1D_kernel)
+                f = theano.function([], bilin_mat, mode=self.compile_mode)
+                up_mat_2d = self.get_upsampled_twobytwo_mat(input_x, ratio)
+                utt.assert_allclose(f(), up_mat_2d, rtol=1e-06)
+
     def test_compare_1D_and_2D_upsampling_values(self):
         """Compare 1D and 2D upsampling
Repository: Theano/Theano

Issue:
Print name of Variable in errors raised by calling a function
See #4063 for an example.
It would be better to print `'x'` in addition to "at index 0(0-based)".



Discussion:

Resolving patch:
diff --git a/theano/compile/function_module.py b/theano/compile/function_module.py
--- a/theano/compile/function_module.py
+++ b/theano/compile/function_module.py
@@ -822,10 +822,14 @@ def __call__(self, *args, **kwargs):
 
                     except Exception as e:
                         function_name = "theano function"
+                        argument_name = "argument"
                         if self.name:
-                            function_name += ' with name "' + self.name + '" '
-                        e.args = ("Bad input argument to " + function_name +
-                                  " at index %d(0-based)" % i,) + e.args
+                            function_name += ' with name "' + self.name + '"'
+                        if hasattr(arg, 'name') and arg.name:
+                            argument_name += ' with name "' + arg.name + '"'
+                        e.args = ("Bad input " + argument_name + " to " +
+                                  function_name + " at index %d (0-based)"
+                                  % i,) + e.args
                         raise
                 s.provided += 1
                 i += 1


Test patch:
Repository: Theano/Theano

Issue:
d3viz doesn't work for some graphs
Sometimes d3viz doesn't work for me - empty graph is displayed, and there is an error message in JS console. I tried to reduce it to a minimal example

``` py
import os    
os.environ['THEANO_FLAGS'] = "device=gpu0,floatX=float32" #,optimizer=fast_compile"

import numpy as np
from lasagne.updates import adam
from theano import tensor as T, shared, function
import theano.d3viz as d3v

def show_d3(g):
    d3v.d3viz(g, 'example.html')
    from IPython.display import IFrame
    return IFrame('example.html', width=800, height=500)

x = T.fvector()
W = shared(np.zeros((10, 5), dtype=np.float32))
b = shared(np.zeros((10,), dtype=np.float32))
y_true = T.fvector()

y = T.nnet.sigmoid(T.dot(x, W) + b)
cost = T.sqrt(((y - y_true)**2).sum())

updates = adam(cost, [W])  # no b!
f_cost = function([x, y_true], cost, updates=updates)
show_d3(f_cost)
```

(IPython notebook: https://gist.github.com/kmike/13b0fb747dccd4f2f1e44789a9cb832c).
This is brittle: if `adam` is replaced with any other training method from Lasagne (or if a simple SGD is implemented manually) chart works; if `T.sqrt` is removed from `cost` expression chart works; if `T.nnet sigmoid` is removed from `y` expression chart works; if `b` is added to adam updates chart works; if `optimizer=fast_compile` is added to THEANO_FLAGS chart works.



Discussion:

Resolving patch:
diff --git a/theano/d3viz/d3viz.py b/theano/d3viz/d3viz.py
--- a/theano/d3viz/d3viz.py
+++ b/theano/d3viz/d3viz.py
@@ -5,8 +5,8 @@
 from __future__ import absolute_import, print_function, division
 
 import os
+import json
 import shutil
-import re
 import six
 from six import iteritems
 
@@ -31,16 +31,15 @@ def replace_patterns(x, replace):
     return x
 
 
-def escape_quotes(s):
-    """Escape quotes in string.
+def safe_json(obj):
+    """Encode `obj` to JSON so that it can be embedded safely inside HTML.
 
     Parameters
     ----------
-    s : str
-        String on which function is applied
+    obj : object
+        object to serialize
     """
-    s = re.sub(r'''(['"])''', r'\\\1', s)
-    return s
+    return json.dumps(obj).replace('<', '\\u003c')
 
 
 def d3viz(fct, outfile, copy_deps=True, *args, **kwargs):
@@ -79,10 +78,9 @@ def d3viz(fct, outfile, copy_deps=True, *args, **kwargs):
     # Create DOT graph
     formatter = PyDotFormatter(*args, **kwargs)
     graph = formatter(fct)
-    dot_graph_raw = graph.create_dot()
+    dot_graph = graph.create_dot()
     if not six.PY2:
-        dot_graph_raw = dot_graph_raw.decode('utf8')
-    dot_graph = escape_quotes(dot_graph_raw).replace('\n', '').replace('\r', '')
+        dot_graph = dot_graph.decode('utf8')
 
     # Create output directory if not existing
     outdir = os.path.dirname(outfile)
@@ -109,7 +107,7 @@ def d3viz(fct, outfile, copy_deps=True, *args, **kwargs):
     replace = {
         '%% JS_DIR %%': os.path.join(dst_deps, 'js'),
         '%% CSS_DIR %%': os.path.join(dst_deps, 'css'),
-        '%% DOT_GRAPH %%': dot_graph,
+        '%% DOT_GRAPH %%': safe_json(dot_graph),
     }
     html = replace_patterns(template, replace)
 


Test patch:
Repository: Theano/Theano

Issue:
gpuarray: compiler-bindir passed to g++
Perhaps this is something specific to my system, perhaps not. If I have the `nvcc.compiler_bindir` config option set, the `theano.gpuarray.dnn` functions do not compile. The tests produce errors like these:

```
test_softmax (theano.gpuarray.tests.test_dnn.TestDnnInferShapes) ... SKIP: cannot compile with cuDNN. We got this error:
g++: error: unrecognized command line option ‘--compiler-bindir’
```

My suspicion is that this is caused by the code in [theano/gpuarray/dnn.py#L70-L71](https://github.com/Theano/Theano/blob/master/theano/gpuarray/dnn.py#L70-L71) that adds `--compiler-bindir` to the list of arguments:

``` python
    if config.nvcc.compiler_bindir:
        params.extend(['--compiler-bindir', config.nvcc.compiler_bindir])
# ...
    avail, out, err = GCC_compiler.try_flags(
        params, preambule=preambule, body=body,
        try_run=False, output=True)
```

If I remove the lines that add the parameter, everything works.

This code seems to be similar to that in `theano/sandbox/cuda/__init__.py`, with the difference that the gpuarray code runs g++, which doesn't accept the argument, and the sandbox code calls nvcc, which does:

``` python

            if config.nvcc.compiler_bindir:
                params.extend(['--compiler-bindir',
                               '%s%s%s' % (path_wrapper, config.nvcc.compiler_bindir, path_wrapper)])
# ...
            comp, out, err = nvcc_compiler.NVCC_compiler.try_flags(
                flag_list=params, preambule=preambule, body=body,
                try_run=False, output=True)
```

Is this a bug in the code or is this something specific to my setup?



Discussion:
It is an issue in Theano.
Passing `nvcc` options to `g++` looks like a bad idea in general...
@abergeron what do you think the fix should be?


Resolving patch:
diff --git a/theano/gpuarray/dnn.py b/theano/gpuarray/dnn.py
--- a/theano/gpuarray/dnn.py
+++ b/theano/gpuarray/dnn.py
@@ -67,8 +67,6 @@ def _dnn_check_compile():
         params.append("-I" + config.dnn.include_path)
     if config.dnn.library_path:
         params.append("-L" + config.dnn.library_path)
-    if config.nvcc.compiler_bindir:
-        params.extend(['--compiler-bindir', config.nvcc.compiler_bindir])
     # Do not run here the test program. It would run on the
     # default gpu, not the one selected by the user. If mixed
     # GPU are installed or if the GPUs are configured in


Test patch:
Repository: Theano/Theano

Issue:
Theano deprecation warning
I have started running my code with warnings as errors.  Theano trips the deprecation warning:

```
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/configparser.py", line 1209, in __init__
    DeprecationWarning, stacklevel=2
DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in future versions. Use ConfigParser directly instead.
```

Please use:

```
theano_cfg =  (ConfigParser.ConfigParser if six.PY3 else ConfigParser.SafeConfigParser)(…
```



Discussion:
Can gpu make a pr for this? Did you saw other such errors?

Le 6 août 2016 21:51, "Neil" notifications@github.com a écrit :

> I have started running my code with warnings as errors. Theano trips the
> deprecation warning:
> 
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/configparser.py", line 1209, in **init**
>     DeprecationWarning, stacklevel=2
> DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in future versions. Use ConfigParser directly instead.
> 
> Please use:
> 
> theano_cfg = (ConfigParser.ConfigParser if six.PY3 else ConfigParse.SafeConfigParser)(…
> 
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> https://github.com/Theano/Theano/issues/4832, or mute the thread
> https://github.com/notifications/unsubscribe-auth/AALC-8qPJUsN0Nvlf0W9rYLdHZgY1xAJks5qdToSgaJpZM4JeZ7s
> .

Sure, I will make a pull request soon.  I think I disabled warnings again for now.  To enable warnings do:

```
import warnings
warnings.simplefilter("error")
```

I don't see this warning with python 3.3 and 3.5 and Theano dev version. We don't support python 3.2. How do you reproduce this?

```
import scipy.special
import warnings
warnings.simplefilter("error")
import theano
```

will trip it in 3.5.

(Peripheral issue https://github.com/scipy/scipy/issues/6587)

@NeilGirdhar  - May I submit a PR for this?

@medakk yes please :)


Resolving patch:
diff --git a/theano/configparser.py b/theano/configparser.py
--- a/theano/configparser.py
+++ b/theano/configparser.py
@@ -10,7 +10,7 @@
 import warnings
 from functools import wraps
 
-from six import StringIO
+from six import StringIO, PY3
 
 import theano
 from theano.compat import configparser as ConfigParser
@@ -73,7 +73,8 @@ def config_files_from_theanorc():
 
 
 config_files = config_files_from_theanorc()
-theano_cfg = ConfigParser.SafeConfigParser(
+theano_cfg = (ConfigParser.ConfigParser if PY3
+              else ConfigParser.SafeConfigParser)(
     {'USER': os.getenv("USER", os.path.split(os.path.expanduser('~'))[-1]),
      'LSCRATCH': os.getenv("LSCRATCH", ""),
      'TMPDIR': os.getenv("TMPDIR", ""),


Test patch: