diff --git a/IPython/lib/pretty.py b/IPython/lib/pretty.py
index cbbb72600..9181113e3 100644
--- a/IPython/lib/pretty.py
+++ b/IPython/lib/pretty.py
@@ -392,6 +392,10 @@ def pretty(self, obj):
                             meth = cls._repr_pretty_
                             if callable(meth):
                                 return meth(obj, self, cycle)
+                        if cls is not object \
+                                and callable(cls.__dict__.get('__repr__')):
+                            return _repr_pprint(obj, self, cycle)
+
             return _default_pprint(obj, self, cycle)
         finally:
             self.end_group()
@@ -537,17 +541,12 @@ def _default_pprint(obj, p, cycle):
     p.end_group(1, '>')
 
 
-def _seq_pprinter_factory(start, end, basetype):
+def _seq_pprinter_factory(start, end):
     """
     Factory that returns a pprint function useful for sequences.  Used by
     the default pprint for tuples, dicts, and lists.
     """
     def inner(obj, p, cycle):
-        typ = type(obj)
-        if basetype is not None and typ is not basetype and typ.__repr__ != basetype.__repr__:
-            # If the subclass provides its own repr, use it instead.
-            return p.text(typ.__repr__(obj))
-
         if cycle:
             return p.text(start + '...' + end)
         step = len(start)
@@ -564,21 +563,16 @@ def inner(obj, p, cycle):
     return inner
 
 
-def _set_pprinter_factory(start, end, basetype):
+def _set_pprinter_factory(start, end):
     """
     Factory that returns a pprint function useful for sets and frozensets.
     """
     def inner(obj, p, cycle):
-        typ = type(obj)
-        if basetype is not None and typ is not basetype and typ.__repr__ != basetype.__repr__:
-            # If the subclass provides its own repr, use it instead.
-            return p.text(typ.__repr__(obj))
-
         if cycle:
             return p.text(start + '...' + end)
         if len(obj) == 0:
             # Special case.
-            p.text(basetype.__name__ + '()')
+            p.text(type(obj).__name__ + '()')
         else:
             step = len(start)
             p.begin_group(step, start)
@@ -596,17 +590,12 @@ def inner(obj, p, cycle):
     return inner
 
 
-def _dict_pprinter_factory(start, end, basetype=None):
+def _dict_pprinter_factory(start, end):
     """
     Factory that returns a pprint function used by the default pprint of
     dicts and dict proxies.
     """
     def inner(obj, p, cycle):
-        typ = type(obj)
-        if basetype is not None and typ is not basetype and typ.__repr__ != basetype.__repr__:
-            # If the subclass provides its own repr, use it instead.
-            return p.text(typ.__repr__(obj))
-
         if cycle:
             return p.text('{...}')
         step = len(start)
@@ -745,12 +734,12 @@ def _exception_pprint(obj, p, cycle):
     int:                        _repr_pprint,
     float:                      _repr_pprint,
     str:                        _repr_pprint,
-    tuple:                      _seq_pprinter_factory('(', ')', tuple),
-    list:                       _seq_pprinter_factory('[', ']', list),
-    dict:                       _dict_pprinter_factory('{', '}', dict),
+    tuple:                      _seq_pprinter_factory('(', ')'),
+    list:                       _seq_pprinter_factory('[', ']'),
+    dict:                       _dict_pprinter_factory('{', '}'),
     
-    set:                        _set_pprinter_factory('{', '}', set),
-    frozenset:                  _set_pprinter_factory('frozenset({', '})', frozenset),
+    set:                        _set_pprinter_factory('{', '}'),
+    frozenset:                  _set_pprinter_factory('frozenset({', '})'),
     super:                      _super_pprint,
     _re_pattern_type:           _re_pattern_pprint,
     type:                       _type_pprint,

OrderedDict output differs in ipython from python (and official documentation)
[collections — Container datatypes](https://docs.python.org/3/library/collections.html#collections.OrderedDict)

An ordered dictionary can be combined with the Counter class so that the counter remembers the order elements are first encountered:

```
from collections import Counter, OrderedDict

class OrderedCounter(Counter, OrderedDict):
    'Counter that remembers the order elements are first encountered'

    def __repr__(self):
        return '%s(%r)' % (self.__class__.__name__, OrderedDict(self))

    def __reduce__(self):
        return self.__class__, (OrderedDict(self),)
```
This is based off a Raymond Hettinger - Super considered super! - PyCon 2015, and his blog post [Python’s super() considered super!](https://rhettinger.wordpress.com/2011/05/26/super-considered-super/).

My confusion is IPython returns a result that differs from the Python it's built on.  The ordering of the output is important and the recipe in Hettinger's blog and the official documentation preserves the insertion order but IPython 6.1.0 built on Python 3.6.3 does not.  However if I execute directly in Python 3.6.3 I receive the expected desired result.

`oc = OrderedCounter('abracadabra')`

output in Python 3.6.3 (and Python 2.7.14)
`OrderedCounter(OrderedDict([('a', 5), ('b', 2), ('r', 2), ('c', 1), ('d', 1)]))`

output in IPython 6.1.0 on Python 3.6.3 Anaconda
`OrderedCounter({'a': 5, 'b': 2, 'c': 1, 'd': 1, 'r': 2})`  //ordering is not preserved, seems sorted by key

Would someone kindly explain why the output is different in IPython 6.1.0
diff --git a/IPython/core/tests/test_formatters.py b/IPython/core/tests/test_formatters.py
index 35edc75d1..cde43c94a 100644
--- a/IPython/core/tests/test_formatters.py
+++ b/IPython/core/tests/test_formatters.py
@@ -49,7 +49,7 @@ def test_pretty():
     f = PlainTextFormatter()
     f.for_type(A, foo_printer)
     nt.assert_equal(f(A()), 'foo')
-    nt.assert_equal(f(B()), 'foo')
+    nt.assert_equal(f(B()), 'B()')
     nt.assert_equal(f(GoodPretty()), 'foo')
     # Just don't raise an exception for the following:
     f(BadPretty())
diff --git a/IPython/lib/tests/test_pretty.py b/IPython/lib/tests/test_pretty.py
index 6d6574345..68e90ecae 100644
--- a/IPython/lib/tests/test_pretty.py
+++ b/IPython/lib/tests/test_pretty.py
@@ -420,4 +420,24 @@ def meaning_of_life(question=None):
         return "Don't panic"
 
     nt.assert_in('meaning_of_life(question=None)', pretty.pretty(meaning_of_life))
-    
+
+
+class OrderedCounter(Counter, OrderedDict):
+    'Counter that remembers the order elements are first encountered'
+
+    def __repr__(self):
+        return '%s(%r)' % (self.__class__.__name__, OrderedDict(self))
+
+    def __reduce__(self):
+        return self.__class__, (OrderedDict(self),)
+
+class MySet(set):  # Override repr of a basic type
+    def __repr__(self):
+        return 'mine'
+
+def test_custom_repr():
+    """A custom repr should override a pretty printer for a parent type"""
+    oc = OrderedCounter("abracadabra")
+    nt.assert_in("OrderedCounter(OrderedDict", pretty.pretty(oc))
+
+    nt.assert_equal(pretty.pretty(MySet()), 'mine')

pip install -e .[test]
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==25.3.0
backcall==0.2.0
certifi==2025.1.31
charset-normalizer==3.4.1
decorator==5.2.1
exceptiongroup==1.2.2
fastjsonschema==2.21.1
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.1.0
ipykernel==5.5.6
-e git+https://github.com/ipython/ipython.git@38e0033a6cf59136208b998c394ac5472b9c1849#egg=ipython
ipython-genutils==0.2.0
jedi==0.19.2
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
jupyter_client==8.6.3
jupyter_core==5.7.2
nbformat==5.10.4
nose==1.3.7
numpy==2.0.2
packaging==24.2
parso==0.8.4
pexpect==4.9.0
pickleshare==0.7.5
platformdirs==4.3.7
pluggy==1.5.0
prompt-toolkit==1.0.18
ptyprocess==0.7.0
Pygments==2.19.1
pytest==8.3.5
python-dateutil==2.9.0.post0
pyzmq==26.3.0
referencing==0.36.2
requests==2.32.3
rpds-py==0.24.0
simplegeneric==0.8.1
six==1.17.0
testpath==0.6.0
tomli==2.2.1
tornado==6.4.2
traitlets==5.14.3
typing_extensions==4.13.0
urllib3==2.3.0
wcwidth==0.2.13
zipp==3.21.0

name: ipython
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==25.3.0
      - backcall==0.2.0
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - decorator==5.2.1
      - exceptiongroup==1.2.2
      - fastjsonschema==2.21.1
      - idna==3.10
      - importlib-metadata==8.6.1
      - iniconfig==2.1.0
      - ipykernel==5.5.6
      - ipython-genutils==0.2.0
      - jedi==0.19.2
      - jsonschema==4.23.0
      - jsonschema-specifications==2024.10.1
      - jupyter-client==8.6.3
      - jupyter-core==5.7.2
      - nbformat==5.10.4
      - nose==1.3.7
      - numpy==2.0.2
      - packaging==24.2
      - parso==0.8.4
      - pexpect==4.9.0
      - pickleshare==0.7.5
      - platformdirs==4.3.7
      - pluggy==1.5.0
      - prompt-toolkit==1.0.18
      - ptyprocess==0.7.0
      - pygments==2.19.1
      - pytest==8.3.5
      - python-dateutil==2.9.0.post0
      - pyzmq==26.3.0
      - referencing==0.36.2
      - requests==2.32.3
      - rpds-py==0.24.0
      - simplegeneric==0.8.1
      - six==1.17.0
      - testpath==0.6.0
      - tomli==2.2.1
      - tornado==6.4.2
      - traitlets==5.14.3
      - typing-extensions==4.13.0
      - urllib3==2.3.0
      - wcwidth==0.2.13
      - zipp==3.21.0
prefix: /opt/conda/envs/ipython

IPython/core/tests/test_formatters.py::test_pretty IPython/lib/tests/test_pretty.py::test_custom_repr
IPython/core/tests/test_formatters.py::test_error_method IPython/core/tests/test_formatters.py::test_warn_error_for_type IPython/core/tests/test_formatters.py::test_error_pretty_method IPython/core/tests/test_formatters.py::test_bad_repr_traceback IPython/core/tests/test_formatters.py::test_ipython_display_formatter IPython/core/tests/test_formatters.py::test_repr_mime IPython/core/tests/test_formatters.py::test_pass_correct_include_exclude IPython/core/tests/test_formatters.py::test_repr_mime_meta IPython/core/tests/test_formatters.py::test_repr_mime_failure
IPython/core/tests/test_formatters.py::test_deferred IPython/core/tests/test_formatters.py::test_precision IPython/core/tests/test_formatters.py::test_bad_precision IPython/core/tests/test_formatters.py::test_for_type IPython/core/tests/test_formatters.py::test_for_type_string IPython/core/tests/test_formatters.py::test_for_type_by_name IPython/core/tests/test_formatters.py::test_lookup IPython/core/tests/test_formatters.py::test_lookup_string IPython/core/tests/test_formatters.py::test_lookup_by_type IPython/core/tests/test_formatters.py::test_lookup_by_type_string IPython/core/tests/test_formatters.py::test_in_formatter IPython/core/tests/test_formatters.py::test_string_in_formatter IPython/core/tests/test_formatters.py::test_pop IPython/core/tests/test_formatters.py::test_pop_string IPython/core/tests/test_formatters.py::test_nowarn_notimplemented IPython/core/tests/test_formatters.py::test_pdf_formatter IPython/core/tests/test_formatters.py::test_print_method_bound IPython/core/tests/test_formatters.py::test_print_method_weird IPython/core/tests/test_formatters.py::test_format_config IPython/core/tests/test_formatters.py::test_pretty_max_seq_length IPython/core/tests/test_formatters.py::test_json_as_string_deprecated IPython/lib/tests/test_pretty.py::test_indentation IPython/lib/tests/test_pretty.py::test_dispatch IPython/lib/tests/test_pretty.py::test_callability_checking IPython/lib/tests/test_pretty.py::test_pprint_heap_allocated_type IPython/lib/tests/test_pretty.py::test_pprint_nomod IPython/lib/tests/test_pretty.py::test_pprint_break IPython/lib/tests/test_pretty.py::test_pprint_break_repr IPython/lib/tests/test_pretty.py::test_bad_repr IPython/lib/tests/test_pretty.py::test_really_bad_repr IPython/lib/tests/test_pretty.py::TestsPretty::test_long_dict IPython/lib/tests/test_pretty.py::TestsPretty::test_long_list IPython/lib/tests/test_pretty.py::TestsPretty::test_long_set IPython/lib/tests/test_pretty.py::TestsPretty::test_long_tuple IPython/lib/tests/test_pretty.py::TestsPretty::test_super_repr IPython/lib/tests/test_pretty.py::TestsPretty::test_unbound_method IPython/lib/tests/test_pretty.py::test_metaclass_repr IPython/lib/tests/test_pretty.py::test_unicode_repr IPython/lib/tests/test_pretty.py::test_basic_class IPython/lib/tests/test_pretty.py::test_collections_defaultdict IPython/lib/tests/test_pretty.py::test_collections_ordereddict IPython/lib/tests/test_pretty.py::test_collections_deque IPython/lib/tests/test_pretty.py::test_collections_counter IPython/lib/tests/test_pretty.py::test_mappingproxy IPython/lib/tests/test_pretty.py::test_function_pretty
IPython/lib/pretty.py
IPython/lib/pretty.py